Error while calling sharepoint function.

Hello All,

 

Microsoft Dynamics NAV
---------------------------

A call to SharepointIntegrationClass.SharepointIntegrationClass.MoveScanDocFromNav failed with this message: The type of one or more arguments does not match the method's parameter type.
---------------------------
OK
---------------------------

 

Its really weird that error is coming while calling it from the NAV.I have created a function in sharepoint MoveScanDocFromNav with three parameter of string type and same data type I am passing,while calling from the Navision.

 

 

Same thing I have tried while in sharepoint Its working fine.

 

 

Thanks in Advance.

 

  • I would like to add more information on this that from same class I am able to use others method but others are not giving any error.
  • Hey Guys Please suggest me whats going wrong with my nav code or C# code anything I am missing in thisintegration scenario.
    In NAV -

    VariableUsed-
    Name-
    SharePointG

    DataType-
    DotNet

    Subtype-
    SharepointIntegrationClass.SharepointIntegrationClass.'SharepointIntegrationClass,Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c6224add99e76a0'

    CODE-
    SharePointG := SharePointG.SharepointIntegrationClass();
    SharePointG.MoveScanDocFromNav('xyz','xvghty','aaaaaaaaa');

    C# code-
    public bool MoveScanDocFromNav(string ListName, string ScanID,string DealNo)
    {
    SPList.Lists lists = new SPList.Lists();
    lists.Url = _SiteUrl + "/_vti_bin/Lists.asmx";
    lists.Credentials = new System.Net.NetworkCredential(_UserID, _Password, _Domain);

    XmlDocument xmlDoc = new XmlDocument();
    XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
    XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
    XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
    queryOptions.InnerXml = @"<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
    <ViewAttributes Scope='RecursiveAll'/>
    <DateInUtc>TRUE</DateInUtc>";
    viewFields.InnerXml = "";
    query.InnerXml = @"";

    XmlNode ndListItems = lists.GetListItems("RTN", null, null, null, null, queryOptions, null);

    xmlDoc.LoadXml(ndListItems.OuterXml);
    XmlNodeList folders = xmlDoc.GetElementsByTagName("z:row");
    string folderDetails = "";

    foreach (XmlNode folder in folders)
    {
    folderDetails += "Title: " + folder.Attributes["ows_FileRef"].Value + "\n" + "";
    if (folderDetails.Contains(ScanID))
    {
    if (folderDetails.Contains(".pdf"))
    {
    CopyDocuments(folder.Attributes["ows_FileRef"].Value, DealNo, ScanID);
    }
    }
    }
    return true;
    }
    public string CopyDocuments(string url, string DealNo, string ScanID)
    {
    try
    {
    string srtDealNo = DealNo;
    string Year = "2016";
    string RegionNo = srtDealNo.Substring(0, 3);
    string StoreNo = srtDealNo.Substring(0, 6);
    string CycleNo = srtDealNo.Substring(0, 9);
    CreateSubFolderFolder("RTN", Year, RegionNo, StoreNo, CycleNo, DealNo);
    SPCopy.Copy myCopyService = new SPCopy.Copy();
    myCopyService.Credentials =
    System.Net.CredentialCache.DefaultCredentials;
    myCopyService.Credentials = new System.Net.NetworkCredential(_UserID, _Password, _Domain);
    string[] copySource = url.Split('#');
    string finalURL = _SiteUrl + copySource[1];
    string DocumentType = "";
    if (finalURL.Contains("Contract"))
    {
    DocumentType = "Contract";
    }
    if (finalURL.Contains("AdCopy"))
    {
    DocumentType = "AdCopy";
    }

    string strDesUR = _SiteUrl + "RTN/" + Year + "/" + RegionNo + "/" + StoreNo + "/" + CycleNo + "/" + DealNo + "/" + DocumentType + "/" + DocumentType + ".pdf";
    string[] copyDest = { strDesUR, strDesUR };
    SPCopy.FieldInformation myFieldInfo = new
    SPCopy.FieldInformation();
    SPCopy.FieldInformation[] myFieldInfoArray = { myFieldInfo };
    byte[] myByteArray;
    uint myGetUint = myCopyService.GetItem(finalURL,
    out myFieldInfoArray, out myByteArray);

    SPCopy.CopyResult myCopyResult1 = new SPCopy.CopyResult();
    SPCopy.CopyResult myCopyResult2 = new SPCopy.CopyResult();
    SPCopy.CopyResult[] myCopyResultArray = { myCopyResult1, myCopyResult2 };
    try
    {
    uint myCopyUint = myCopyService.CopyIntoItems(finalURL, copyDest,
    myFieldInfoArray, myByteArray, out myCopyResultArray);
    if (myCopyUint == 0)
    {
    int idx = 0;
    foreach (SPCopy.CopyResult myCopyResult in myCopyResultArray)
    {
    string opString = (idx + 1).ToString();
    if (myCopyResultArray[idx].ErrorMessage == null)
    {
    return "Copy operation complete";
    }
    else
    {
    return "Error!!!";
    }
    idx++;
    }
    }
    return "Copy operation complete";
    }
    catch (Exception exc)
    {
    return exc.Message;
    }

    }
    catch (Exception ex)
    {
    return ex.Message;
    }
    }
  • In reply to Vivek Rawat:

    Hello All,

    I have found the solution for my error after struggling so much...

    Its really strange that the error what is coming is totally doesn't match the solution what I got.

    What I have done-

    I opened NAV administration service and change the SQL Command Timeout which is default 00:00:30 changed to the 10:00:00 and after that restart the service.

    Solved the problem..Geeked.

Related