Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

i have retrived newly created ID of inserted document ,but when i called method so it doesnot wait to get new ID of document..and gohead fast

$
0
0

Hi,

I have retrieved newly inserted ID of document using web api of json like this

   var returnfalg = uploadFile(response.d); // uploadfile is calling web api to insert and updated document and its metadata_
            alert(returnfalg);

     

// problem here goes to call below method till then ID is not created

            RetrivedocumentRepeater(returnfalg);

I stored ID of newly created document like this in getitem.dont method

  getItem.done(function (listItem, status, xhr) {
                    console.log(listItem.d.ID);
                    falg = listItem.d.ID;  ///  falg is variable which I declared in uploadfile method
                    alert(listItem.d.ID);

problem:

as I call my method by passing ID to retrive record its fired first till than NewID is new created ( as above I mentioned my other method which name is "  RetrivedocumentRepeater(returnfalg);"

which is web api no C# json called

    function RetrivedocumentRepeater(docid_) {
        var obj = {};
        obj.docname = $('#displayName').val();
        obj.siteurl = _spPageContextInfo.siteAbsoluteUrl;
        obj.docid = docid_;
    
        $.ajax({
            type: "POST",
            url: "/_layouts/15/Dejavu/DejavuAddDocuments.aspx/RetriveDocByID",
            data: JSON.stringify(obj),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccesretrive,
            failure: function (response) {
                alert('Not Try again after refreshing page');
            }
        });
        return false;
    }
    function OnSuccesretrive(response) {
        if (response.d.length > 0) {
            //alert('upload done');
            $('#tbluploaddoc tbody').prepend('<tr id=tr_' + response.d[0].DocID + '> <td> <a href="#" id="lnkview_"' + response.d[0].DocID + '"><b>' + response.d[0].DocName + '  </b> </a> </td> <td>  <b>' + response.d[0].DocType + '  </b> </td >  <td>  <b>' + response.d[0].Docstatus + ' </b></td>  <td><input type="button" name="Download_" class="download_css"  id="' + response.d[0].documenturl + '" value="Downnload" />  </td>  <td class="btnsharedcss"> <input type="button" class="Shared_"  id="' + response.d[0].DocID + '"value="SHARED"  /> </td>   </tr > ');
            clearui();
            alert('Uploaded successfully.');
        }
    }

Guide me:

How and when to pass newly createdID of document to retrive data from document library...becase it doesnot wait and go ahead to call my method...


Viewing all articles
Browse latest Browse all 7589

Trending Articles