0

I made a custom list and in the other side I made a apps, in fact it is a form that I have done with html + css + JS using visual studio and deploying my solution in sharepoint online. my question is how to insert the data from my list in the appropriate fields on the form. Is there a JS instruction that makes this stuff?

  • What kind of app is this? SharePoint-hosted? Provider-hosted? Where did you create the list? In the app or on the site? – wjervis Aug 14 '14 at 11:50
1

Where is the list located? Is it inside the same app web or the host web? If it is app web, then follow this article.

If it is the host web, then you need to enable permissions in the app permissions to read list. Then access the host web voa javascript. All need to be done with JS Async calls.

1

In order to get data from your list to your form, you will need to use either CSOM (JSOM or C#, depending on how your app is hosted) or REST.

See these links on how to get list items:

If the list is on the host web, and you are trying to get items from the app, you will need to use the Cross-Domain Library, Sp.RequestExecutor.js.

Here is a sample to get list items via JSOM (I can update to any other method, but to keep this short, I'm only including one method):

function retrieveListItems(siteUrl) {
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Announcements');

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml(
        '<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + 
        '<Value Type=\'Number\'>1</Value></Geq></Where></Query>' + 
        '<RowLimit>10</RowLimit></View>'
    );
    this.collListItem = oList.getItems(camlQuery);

    clientContext.load(collListItem);
    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded), 
        Function.createDelegate(this, this.onQueryFailed)
    ); 
}

function onQuerySucceeded(sender, args) {
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        listItemInfo += '\nID: ' + oListItem.get_id() + 
            '\nTitle: ' + oListItem.get_item('Title') + 
            '\nBody: ' + oListItem.get_item('Body');
    }

    alert(listItemInfo.toString());
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + 
        '\n' + args.get_stackTrace());
}
0

I'm not sure if I understand the question correctly, but I think you have a completely new customized webform that has absolutely no connection to SharePoint. And now you want that form to include data from a SharePoint list item using html + css + jss, is this correct?

Microsoft has good documentation on this, if you go through this I'm confident you'll know what to do:

http://msdn.microsoft.com/en-us/library/office/dn531433(v=office.15).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.