resource custom fields psi update

V

Vybez

Hi,

I have some resource custom fields that get their values from a lookup
table, e.g Job Title.
I need to update the resource details including the custom fields via PSI,
but I've only been able to get access to the predefined ones only. e.g
resourceRow.RES_NAME.
How can I be able to update the custom fields as well using PSI.

Any ideas will be appreciated with much gratitude.
 
B

Brian Smith \(MSFT\)

Hi Vybez,

Resource custom fields can be set via the ResourceCustomFieldsRow of the
dataset. If the row for a specific field is already in the dataset you can
update the value, if not then you need to add a row and identify which
custom field this row relates to, and then set the value. See the SDK for
more details, although samples are currently lacking for adding fields. If
you read in a dataset containing a resource with fields I am sure you will
get the idea of how they need to be added The same applies to custom fields
for other entities such as projects and tasks.

Best regards,

Brian
 
V

Vybez

Hi Brian,

Thanx for your response.

I did use the ResourceCustomFields.DataSet. It's got 5 tables and none of
them have what I'm looking for.
I tried playing around but, I don't seem to be coming out right.
Do you perhaps have an example or just sample code.

Regards,

Godfrey
 
B

Brian Smith \(MSFT\)

Hi Godfrey,

Unfortunately I don't have samples to hand - but if you look at the ProjTool
sample that ships with the SDK, and particularly at the ProjCFDlg.cs file it
shows how the tool sets custom fields for Projects.

The steps you need are to add a ResourceCustomFieldsRow to your dataset
which can have the following properties:-

CUSTOM_FIELD_UID Specifies the unique ID for the custom field value.
MD_PROP_UID Specifies a unique ID for this custom field definition.
MD_PROP_ID Specifies an integer-formatted unique ID for this custom field
definition.
RES_UID Specifies the unique ID of the resource to which this custom field
belongs.

FIELD_TYPE_ENUM Specifies the PSDataType value for this custom field.

CODE_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type GUID.
DATE_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type DATE.

DUR_FMT Specifies the display format you want for the DUR_VALUE property if
the FIELD_TYPE_ENUM property is set to type DURATION.
DUR_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type DURATION.

FLAG_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type YESNO.

NUM_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type NUMBER.
TEXT_VALUE Specifies the value of the custom field if the FIELD_TYPE_ENUM
property is set to type STRING.

So the MD_PROP_UID and ID are in fact lookups to the Guid for the custom
field you are settings, and this will also identify the FIELD_TYPE_ENUM
enumeration. Based on this enumeration which can be GUID, Date, Duration,
YESNO, Number or String the matchine _VALUE field will be set.

Once you have added this row and set the properties then the UpdateResource
method will set the code.
 
V

Vybez

Hi Brian,

Was away for a while.
I have looked at the ProjTool and the SDK.
The documentation and examples seem to only be for creating custom fields
and not for updating already existing ones.

I've tried to get a ResourceCustomFieldsRow by using the
FindByCUSTOM_FIELD_UID method on the ResourceCustomFieldsDataTable, but
there's a problem when initializing a DataRowBuilder which is needed by the
ResourceCustomFieldsRow constructor, because DataRowBuilder's constructor is
internal.
The Error message reads "Cannot access internal constructor 'DataRowBuilder'
here."

Direct database access does not help, because the changes will not reflect
in Project Pro, or Project Web Access.

Regards,
 
H

Heinrich Eichmann

....
The steps you need are to add a ResourceCustomFieldsRow to your dataset
which can have the following properties:-

Hi Brian,

Updating and adding custom fields works this way. But how can I delete them?
I tried RemoveResourceCustomFieldsRow before calling UpdateResources, but
the row did not go away...


Best regards,


Heiner
 
H

Heinrich Eichmann

Updating and adding custom fields works this way. But how can I delete
them? I tried RemoveResourceCustomFieldsRow before calling
UpdateResources, but the row did not go away...

Calling Delete() on the row solved this issue. Thanks to Brian for this
hint,

Best regards,


Heiner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top