Forum Discussion
Awake Kapoor
Nov 26, 2016Copper Contributor
How to create a list in site not in app using SP hosted app
Hi All, I just want to know can we create a list using visual studio while creating SP hosted app in SP online, but the list resides in site on which i am hosting that app not on that particular...
Nov 26, 2016
Yes, it is possible if the list is created after your Add-in is provisioned...if you are thinking on creating the list while the Add-in (SharePoint-Hosted) is provisioned, is not going to be possible. The only way to create the list from your SharePoint-Hosted Add-in is from an action you define there so you can use that action (a button for instance) to create the list in the host site
- Awake KapoorNov 27, 2016Copper ContributorHey Juan thanks for your reply, if i am not wrong you are saying me to create a button and write some REST API code to create list in my host site and call this code on clicking of that button ?
- Nov 27, 2016Yeap, that's what I meant
- Awake KapoorNov 27, 2016Copper ContributorOk Juan, I was trying to create site column of lookup type but there is some coming in my case, could you please help me on this find my code below var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/fields"; $.ajax({ url: requestUri, type: "POST", async : false, data : "{ 'parameters': { '__metadata': { 'type': 'SP.FieldCreationInformation' }, 'FieldTypeKind': 7, 'Title': 'SelectLanguageTest', 'LookupListId': 'cc481bd2-713e-4915-a3fd-7d1fa57df81c', 'LookupFieldName': 'Title' } }", headers: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: onSuccess, error: onError });