none
Project Server 2010: add new resource's lookup custom field using PSI RRS feed

  • Question

  • Hi

    I have 2 resource custom fields. I want these to be populated using PSI.

    I was able to update the RCF for the user who already had values but if none, it is returning an error.

    Error:

    "ForeignKeyConstraint ResourcesResourceCustomFields requires the child key values to exist in the parent table" 

    My Code:

    Guid MDLookUpTableGuid1 = new Guid(cfDs.CustomFields.Select("MD_PROP_UID = '" + CFGuid + "'")[0][cfDs.CustomFields.MD_LOOKUP_TABLE_UIDColumn].ToString());

                            lutDs = LutSvc.ReadLookupTablesByUids(new Guid[] { MDLookUpTableGuid1 }, false, 1033);

                            if (sresDs.ResourceCustomFields.Select("MD_PROP_UID = '" + CFGuid + "'").Length > 0)

                            {

     

                                if (lutDs.LookupTableTrees.Select("LT_VALUE_TEXT = '" + CustomFieldValue + "'").Length > 0)

                                {

                                    LookupSelectedValue = new Guid(lutDs.LookupTableTrees.Select("LT_VALUE_TEXT = '" + CustomFieldValue + "'")[0][lutDs.LookupTableTrees.LT_STRUCT_UIDColumn].ToString());

                                    sresDs.ResourceCustomFields.Select("MD_PROP_UID = '" + CFGuid + "'")[0][sresDs.ResourceCustomFields.CODE_VALUEColumn] = LookupSelectedValue;

                                }

                            }

                            else

                            {

                                ResourceWebSvc.ResourceDataSet.ResourceCustomFieldsRow FunctionCFRow = sresDs.ResourceCustomFields.NewResourceCustomFieldsRow();

                                LookupSelectedValue = new Guid(lutDs.LookupTableTrees.Select("LT_VALUE_TEXT = '" + CustomFieldValue + "'")[0][lutDs.LookupTableTrees.LT_STRUCT_UIDColumn].ToString());

                                FunctionCFRow.RES_UID = ResourceGuid;

                                FunctionCFRow.MD_PROP_UID = CFGuid;

                                FunctionCFRow.CUSTOM_FIELD_UID = Guid.NewGuid();

                                FunctionCFRow.CODE_VALUE = LookupSelectedValue;

                                sresDs.ResourceCustomFields.AddResourceCustomFieldsRow(FunctionCFRow); --- error ""ForeignKeyConstraint ResourcesResourceCustomFields requires the child key values to exist in the parent table" "

                            }

    Thursday, January 11, 2018 8:46 PM