0

So here I am creating a list on a sharepoint app, the app has full control over the host web. I run the code and it does not trigger any exception, but If I check the host site contents, the list does not appear. Is this a normal behavior?

The group creates without any problem

here's a chunk of the code:

    var hostWebContext = new SP.ClientContext(PoxtaOnline.Utils.Url.getQueryStringParameter('SPHostUrl'))
    var hostWeb = hostWebContext.get_web();
    var groupCreateInfo = new SP.GroupCreationInformation();
    var listCreateInfo = new SP.ListCreationInformation();
    var siteGroups = hostWeb.get_siteGroups();
    var siteLists = hostWeb.get_lists();

    groupCreateInfo.set_title(_self.name());
    groupCreateInfo.set_description('Grupo de usuarios correspondiente a la seccion de ' + _self.name());

    listCreateInfo.set_title(_self.name());
    listCreateInfo.set_description('Biblioteca de documentos de Poxta Online para la seccion ' + _self.name());
    listCreateInfo.set_quickLaunchOption(SP.QuickLaunchOptions.off);
    listCreateInfo.set_templateType(SP.ListTemplateType.documentLibrary);

    asyncObjects.sectionGroup = siteGroups.add(groupCreateInfo);
    asyncObjects.sectionList = siteLists.add(listCreateInfo);

    hostWebContext.load(asyncObjects.sectionGroup);
    hostWebContext.load(asyncObjects.sectionList);
    SP.UI.Notify.removeNotification(notification);
    notification = SP.UI.Notify.addNotification('Creando grupo de usuarios y biblioteca de documentos...', true);
    hostWebContext.executeQueryAsync(onCreateGroupAndListSuccess, onError);

1 Answer 1

0

Nevermind, changed

var hostWebContext = new SP.ClientContext(PoxtaOnline.Utils.Url.getQueryStringParameter('SPHostUrl'))

for

var hostWebContext = new SP.AppContextSite(context, PoxtaOnline.Utils.Url.getQueryStringParameter('SPHostUrl'))

and changed this

hostWebContext.load(asyncObjects.sectionGroup);
hostWebContext.load(asyncObjects.sectionList);
SP.UI.Notify.removeNotification(notification);
notification = SP.UI.Notify.addNotification('Creando grupo de usuarios y biblioteca de documentos...', true);
hostWebContext.executeQueryAsync(onCreateGroupAndListSuccess, onError);

for this

context.load(asyncObjects.sectionGroup);
context.load(asyncObjects.sectionList);
SP.UI.Notify.removeNotification(notification);
notification = SP.UI.Notify.addNotification('Creando grupo de usuarios y biblioteca de documentos...', true);
context.executeQueryAsync(onCreateGroupAndListSuccess, onError);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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