none
Jsom: Read custom field task value? RRS feed

  • Question

  • Hi Everyone,

    I'm trying to read custom field task in project server with JSOM, So I've made this code:

        var projUID = ds.GetDataValue(PJ.PSDBField.proJ_UID);
        var taskUID = ds.GetDataValue(PJ.PSDBField.tasK_UID);
        projContext = PS.ProjectContext.get_current();    
        var projects = projContext.get_projects();
        var project = projects.getByGuid(projUID).get_draft();
        var tasks = project.get_tasks();
        task = tasks.getByGuid(taskUID);
        projContext.load(task);
        projContext.executeQueryAsync(GetTask, QueryFailed);
    
       return (true);
    }
    
    function GetTask(){
        CustomFields=task.get_customFields();
        projContext.load(CustomFields);
        projContext.executeQueryAsync(GetCF, QueryFailed);
    }
    
    function GetCF() {
            enumerator=CustomFields.getEnumerator();
          while (enumerator.moveNext()) {
         if (toto.get_name() == fieldName) {
          CustomFieldTaskID=toto.get_id();
        }

    So I have 4 custom fields task but my CustomFields variable lenght is only one, I don't understand why it doesn't see my other fields The field which is seen is Health (wich a by default custom Field)

    Any idea of what I'm doing wrong?

    Thank you for your help

    Monday, March 11, 2019 8:25 PM