how to update project online custom field using SharePoint hosted app model with JSOM


  • Hi,

    I am not able to update project online custom field using JavaScript in SharePoint hosted app model. my same JavaScript code is work fine when i try through script editor window but not working in app model. Can anyone help me where i am doing wrong in app or what type of permission require to deploy the app and what type of permission should be in AppManifest.xml file.

    Below is the my JavaScript code which is working in Script Editor but not in SharePoint hosted app model.

    $(document).ready(function () {
    SP.SOD.executeOrDelayUntilScriptLoaded(ReadCustomFields, "PS.js");

    PS.DraftProject.setCustomFieldValue(FieldName, Value);
    function ReadCustomFields() {
        projectContext = PS.ProjectContext.get_current();
        Allprojects = projectContext.get_projects();
        custom_Fields = projectContext.get_customFields();
        //projectContext.load(Allprojects, 'Include(Name, CreatedDate, Id)');
    function getCF_Complete(response) {
        var cfEnumerator = custom_Fields.getEnumerator();   
        while (cfEnumerator.moveNext()) {
            var cf = cfEnumerator.get_current();
                Id: cf.get_id(),
                Name: cf.get_name(),
                InternalName: cf.get_internalName()
        SP.SOD.executeOrDelayUntilScriptLoaded(update_Project, "PS.js");
    function update_Project() {
        var projectGUID = "a73dcb3b-9901-e811-80ca-00155d1c352a";
        var project = Allprojects.getById(projectGUID);
        var draft_Project = project.checkOut();
        var CustomfieldName = "Testcustomfield";
        var cfData = $.grep(customField_Data, function (val) {
            return val.Name === CustomfieldName;
        if (cfData.length > 0) {
            //alert("Lenght is greater ");
            //draft_Project.setCustomFieldValue(cfData[0].InternalName, "Value Update By APP using JSOM");
            draft_Project.setCustomFieldValue("Custom_079c7f5bdd2be71180c900155d18bd14", "Value Update By APP using JSOM");
        var publish_Job = draft_Project.publish(true);
        projectContext.waitForQueueAsync(publish_Job, 30, function (response) {
            if (response !== 4) {

    Harjinder kumar SharePoint Developer

    Selasa, 07 Agustus 2018 10.15

Semua Balasan