Search a resource Uid by the value of a custom field.

Respondida Search a resource Uid by the value of a custom field.

  • 13 aprilie 2012 09:19
     
      Are cod

    Hi everybody,

    I have some enterprise resources created and a custom field called resourceId for each one. I'm trying to get the RES_UID value but the dataset always get null value. Here I paste the code, can anyone tell me what was wrong?

    // Function that returns the Uid for a enterprise custom field
    Guid? customFieldUId = GetCustomFieldUIdByName("resourceId", EntityTypes.Recursos);
    
    ResourceWebSvc.ResourceDataSet resourceDs = new ResourceWebSvc.ResourceDataSet();
    string tableName = resourceDs.ResourceCustomFields.TableName;
    string cfUidColumn = resourceDs.ResourceCustomFields.MD_PROP_UIDColumn.ColumnName;
    string valueColumn = resourceDs.ResourceCustomFields.NUM_VALUEColumn.ColumnName;
    string resUidColumn = resourceDs.ResourceCustomFields.RES_UIDColumn.ColumnName;
    
    PSLibrary.Filter.FieldOperationType equal = PSLibrary.Filter.FieldOperationType.Equal;
    PSLibrary.Filter.LogicalOperationType and = PSLibrary.Filter.LogicalOperationType.And;
    
    PSLibrary.Filter resourceFilter = new PSLibrary.Filter();
    resourceFilter.FilterTableName = tableName;
    
    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resUidColumn));
                
    PSLibrary.Filter.FieldOperator byCustomFieldUid = new PSLibrary.Filter.FieldOperator(equal, cfUidColumn, customFieldUId);
    PSLibrary.Filter.FieldOperator byIdRecurso = new PSLibrary.Filter.FieldOperator(equal, valueColumn, idRecurso);
    resourceFilter.Criteria = new PSLibrary.Filter.LogicalOperator(and, byCustomFieldUid, byIdRecurso);
    
    resourceDs = resourceSVC.ReadResources(resourceFilter.GetXml(), false);
    // After this, resourceDs is always null 

    Thank you in advanced!

Toate mesajele

  • 15 aprilie 2012 03:25
    Moderator
     
     Răspuns
    Can't help you with this code, but one way is to read from the Reporting db. The Resource_Userview View has all Resource custom fields appended automatically, so search for the value you want and read teh UID.

    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management

    • Marcat ca răspuns de LyE- 16 aprilie 2012 09:04
    •  
  • 16 aprilie 2012 09:07
     
     

    Hi Rod,

    Thank you for your answer... that had been my solution. At leats it was working...