2

I have created a SharePoint Hosted App(Javascript Object Model) that creates lists on the host web.

I need to put some javascript into new and edit forms, a Content Editor, in order to create the cascaded drop down effect on 2 lookup fields. Creating the lists and fields manipulation are made with a press of a button.

Here is the link for the cascaded drop down library: http://spservices.codeplex.com/

Here is how I create the lists and the fields for it:

// Create a new list on host web
    var createList = function (listTitle, onSuccess, onFieldsReady) {
    var listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title(listTitle);
    listCreationInfo.set_templateType(SP.ListTemplateType.genericList);

    var lists = hostWeb.get_lists();
    var newList = lists.add(listCreationInfo);

    currentContext.load(newList);
    currentContext.executeQueryAsync(onSuccess(newList, onFieldsReady), onListCreationFail);
}

    // Create a new field on a list
    var createField = function (list, fieldType, fieldName, fieldDisplayName, fieldRequired, onSuccess) {
    var fields = list.get_fields();
    var fieldXml = "<Field Type='" + fieldType + "' Required='" + fieldRequired + "' DisplayName='" + fieldDisplayName + "' Name='" + fieldName + "'></Field>";
    var createdField = fields.addFieldAsXml(fieldXml, true, SP.AddFieldOptions.addFieldInternalNameHint | SP.AddFieldOptions.addFieldToDefaultView);

    currentContext.load(createdField);
    currentContext.executeQueryAsync(onSuccess, onProvisionFieldFail);
}

Can you please give me some advise?

1 Answer 1

0

For Office 365 and SharePoint 2013, I advise you to see this blog and video:

blog: http://www.markrackley.net/2014/05/20/cascading-drop-down-lists-in-sharepoint-office-365-using-rest/

Video:https://www.youtube.com/watch?v=_B8rV56-y1s

For good reason, without using a library of third parties as "SPServices". It will take a while until you get to practice the REST API, but it's incredible work it.

Bit code and a lot of solution. :)

Hope this help.

Thanks.

Your Answer

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

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