PSI to Read the lookup values associated with each of the task in the project plan RRS feed

  • Question

  • We have defined a custom field(ActivityID) with a lookup table (ActID), in project level as well as on task level. Some user will put this activity ID at the Project Level and some will put at the task level. I can able to read the Activity ID defined at project level.

    Can someone tell me how to read this activity id defined at each task in the project?



    Wednesday, November 30, 2011 7:50 PM

All replies

  • Hi Vivek,

    In the ProjectDataSet there is a "Tasks" table containing the Task Information and a "TaskCustomFields" table containing the task custom field information. The relation between these two tables is the TASK_UID. You can identify your task level custom field by its Guid in the "MD_PROP_UID" column of the TaskCustomFields table. Remember that these are two different custom fields, one on the project level and one on the task level.  

    You can retrieve the Guid of the custom field by its name using the Custom Field PSI using the code below, where Entity is on of the following values





    Hope this helps,






                Cf.CustomFields cf = new Cf.CustomFields();
                cf.Credentials = System.Net.CredentialCache.DefaultCredentials;

                // TaskSkillUid
                Cf.CustomFieldDataSet ds = new Cf.CustomFieldDataSet();
                PSLibrary.Filter filter = new PSLibrary.Filter();
                filter.FilterTableName = ds.CustomFields.TableName;
                PSLibrary.Filter.IOperator[] fos = new PSLibrary.Filter.IOperator[2];
                PSLibrary.Filter.FieldOperator op1 = new PSLibrary.Filter.FieldOperator(PSLibrary.Filter.FieldOperationType.Equal, ds.CustomFields.MD_ENT_TYPE_UIDColumn.ColumnName, new object[] { entityUid });
                PSLibrary.Filter.FieldOperator op2 = new PSLibrary.Filter.FieldOperator(PSLibrary.Filter.FieldOperationType.Equal, ds.CustomFields.MD_PROP_NAMEColumn.ColumnName, new object[] { customFieldName });
                fos[0] = op1;
                fos[1] = op2;
                PSLibrary.Filter.LogicalOperator lo = new PSLibrary.Filter.LogicalOperator(PSLibrary.Filter.LogicalOperationType.And, fos);
                filter.Criteria = lo;
                filter.Fields.Add(new PSLibrary.Filter.Field(ds.CustomFields.TableName, ds.CustomFields.MD_PROP_UIDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.Asc));
                ds = cf.ReadCustomFields(String.Empty, false);
                ds = cf.ReadCustomFields(filter.GetXml(), false);
                return (string)ds.CustomFields.Rows[0][ds.CustomFields.MD_PROP_UIDColumn.ColumnName].ToString();
    • Proposed as answer by Stefan Pirer Thursday, December 1, 2011 2:41 PM
    Wednesday, November 30, 2011 9:25 PM
  • Hi Stefan,

    Thanks for the reply. By using the below code i can able to get the lookup value of Project Custom field for all the projects.

    Can you please tell me how to get the lookup value associated with each task in the project?

                    string[] CF_LT_GuidID = new string[2];
                    CF_LT_GuidID = CustomField("ProjectClient" , 0);
                    Guid CustomFieldGuidID = new Guid(CF_LT_GuidID[0].ToString());
                    Guid LookUpGuidID = new Guid(CF_LT_GuidID[1].ToString());
                    lo_projs = ws_Project.ReadProjectList();
                    DataRowCollection lo_projects = lo_projs.Tables[lo_projs.Project.TableName].Rows;
                     for (int i = 0; i < lo_projects.Count; i++)
                            lo_projGUID = new Guid(lo_projects[i][0].ToString());
                            ls_projName = lo_projects[i][1].ToString();

                                lo_projDS = ws_Project.ReadProjectEntities(lo_projGUID, entities, ResourceVacation.WSProject.DataStoreEnum.WorkingStore);

                                for (int k = 0; k < lo_projDS.ProjectCustomFields.Count; k++)
                                    if (lo_projDS.ProjectCustomFields[k].MD_PROP_UID == CustomFieldGuidID)
                                        lt_Struct_Uid = lo_projDS.ProjectCustomFields[k].CODE_VALUE;

                                Guid[] arrayLTuid = new Guid[1] { LookUpGuidID };

                                ResourceVacation.WSLookupTables.LookupTableDataSet lo_ltDS = new ResourceVacation.WSLookupTables.LookupTableDataSet();
                                lo_ltDS = lo_WSLookupTables.ReadLookupTablesByUids(arrayLTuid, false, 1033);

                                for (int j = 0; j < lo_ltDS.LookupTableTrees.Count; j++)
                                    if (lo_ltDS.LookupTableTrees[j].LT_STRUCT_UID == lt_Struct_Uid)
                                        theLookupTableValue = lo_ltDS.LookupTableTrees[j].LT_VALUE_TEXT.ToString();
                                }    }

    public string[] CustomField(string as_CustomField,int as_LookupExist)
                ms_CFName = as_CustomField;

                ResourceVacation.WSCustomField.CustomFieldDataSet lo_cfDS = new ResourceVacation.WSCustomField.CustomFieldDataSet();

                string tableName = lo_cfDS.CustomFields.TableName;
                string nameColumn = lo_cfDS.CustomFields.MD_PROP_NAMEColumn.ColumnName;
                string uidColumn = lo_cfDS.CustomFields.MD_PROP_UIDColumn.ColumnName;
                string LTColumn = lo_cfDS.CustomFields.MD_LOOKUP_TABLE_UIDColumn.ColumnName;

                PSLibrary.Filter cfFilter = new PSLibrary.Filter();
                PSLibrary.Filter.FieldOperationType equal = PSLibrary.Filter.FieldOperationType.Equal;

                cfFilter.FilterTableName = tableName;

                cfFilter.Fields.Add(new PSLibrary.Filter.Field(tableName, nameColumn));
                cfFilter.Fields.Add(new PSLibrary.Filter.Field(uidColumn));
                cfFilter.Fields.Add(new PSLibrary.Filter.Field(LTColumn));

                cfFilter.Criteria = new PSLibrary.Filter.FieldOperator(equal, nameColumn, as_CustomField);

                lo_cfDS = _cf.ReadCustomFields(cfFilter.GetXml(), false);

                mg_CF = new Guid(lo_cfDS.Tables[lo_cfDS.CustomFields.TableName].Rows[0][lo_cfDS.CustomFields.MD_PROP_UIDColumn.ColumnName].ToString());
                if (as_LookupExist == 0)
                    mg_LT = new Guid(lo_cfDS.Tables[lo_cfDS.CustomFields.TableName].Rows[0][lo_cfDS.CustomFields.MD_LOOKUP_TABLE_UIDColumn.ColumnName].ToString());
                    mg_LT = Guid.Empty;
                string[] CF_LT = new string[2];
                CF_LT[0] = Convert.ToString(mg_CF);
                CF_LT[1] = Convert.ToString(mg_LT);
                return CF_LT;



    Friday, December 2, 2011 6:52 PM
  • Hi Vivek,

    I am new to Project server 2010 and i dont know much about PSI webservices. I have created an enterprise Projectcustom field "Skills" using a lookup table "IT-skills". i want to get value of this custom field .so, i think the code you have posted above can be helpful to me.

    please post the whole code including using directives and tell me what are the webservices included in above code and also tell me the modifications that i should do to the above code.

    thanks in advance.



    Amit Kasundra

    Tuesday, March 13, 2012 6:33 AM