none
Update MS Project custom field using SharePoint hosted app 2013 with JSOM RRS feed

  • Question

  • Hi Team,

    I am unable to update MS project custom field using SharePoint hosted app with java script object model. below is the my code and please help me to update the project custom field and where i am doing wrong.

    $(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)');
        projectContext.load(custom_Fields);
        projectContext.executeQueryAsync(getCF_Complete);
    }
    function getCF_Complete(response) {
        var cfEnumerator = custom_Fields.getEnumerator();   
        while (cfEnumerator.moveNext()) {
            var cf = cfEnumerator.get_current();
            customField_Data.push({
                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";
        alert(CustomfieldName);
        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");
            draft_Project.update();
        }
        alert(cfData[0].InternalName);
        var publish_Job = draft_Project.publish(true);
        projectContext.waitForQueueAsync(publish_Job, 30, function (response) {
            if (response !== 4) {
                    
            }
        });
     

    Harjinder kumar SharePoint Developer

    Monday, July 23, 2018 7:12 AM

All replies