Custom Fields for the Assignment Entity Type

A

albupp

Does anyone know what the story is with regards to setting custom fields on
resource assignments? It appears that the currently this is not supported.
Calling ReadCustomFieldsByEntity interface of the Project server's
CustomFields web service, and passing a "Assignment" as the entity type
argument results in a CustomFieldInvalidEntityUID error. Also, the via
Office Project Web Access' when creating a new enterprise custom field, the
interface only offers choices for Project, Task and Resource entity types.
However, looking at the ProjectDataSet defined by the API, one finds that it
includes a AssignmentCustomFieldsDataTable. What's the point of this table
if there's no way create custom fields associated with an assignment entity?

-Albert
 
M

Martin Winzig

There aren't special custom field for assignments, (You have to use Task and
resource custom fields)


You have to know that instead of
field.MD_PROP_ID
field.MD_PROP_UID

you have to use

field.MD_PROP_ID_SECONDARY and
field.MD_PROP_UID_SECONDARY

from your assignment custom property.
 
A

albupp

Martin,

Thank you for the response to my question.

I'm afraid though that I don't understand what you mean. I can see, now
that you've pointed it out to me, the MD_PROP_ID_SECONDARY &
MD_PROP_UID_SECONDARY properties in the CustomFieldDataSet.CustomFieldsRow
type. However, I don't understand where I get an assignment custom field
GUID from. Is this simply from a CustomFieldsRow instance? If so, what
makes it an "assignment custom field"?

I don't suppose that you could post a code snippet that demonstrates setting
a value in a custom field associated w/ a given assignment?

Thanks again, Albert
 
M

Martin Winzig

assignment custom field are stored in table AssignmentCustomFields
(Projectdataset ) so you should find & update or add new row to this table :)

row.CUSTOM_FIELD_UID = Guid.NewGuid();
row.MD_PROP_UID = field.MD_PROP_UID_SECONDARY;
row.MD_PROP_ID = field.MD_PROP_ID_SECONDARY;
.......
....
 
A

albupp

Martin,

I wanted to give you a belated thanks for taking the time to help me out w/
this. I was finally able to find the time to write a test of your specs, and
it worked like a charm.

For those interested, here's what my working code looks like:

public ProjectDataSet.AssignmentCustomFieldsRow
CreateAssignmentCustomFieldsRow(
ProjectDataSet prjDs,
Guid assnGuid,
Guid cfMdProp2ndGuidStr,
int cfMdProp2ndIdStr)
{
ProjectDataSet.AssignmentCustomFieldsRow assnCfRow = null;
if (prjDs != null) {
assnCfRow = prjDs.AssignmentCustomFields.NewAssignmentCustomFieldsRow();
Guid cfAssnRow = Guid.NewGuid();
assnCfRow.CUSTOM_FIELD_UID = cfAssnRow;
assnCfRow.ASSN_UID = assnGuid;
assnCfRow.MD_PROP_UID = cfMdProp2ndGuid;
assnCfRow.MD_PROP_ID = cfMdProp2ndIdStr;
assnCfRow.PROJ_UID = prjGuid;
}
return assnCfRow;
}

public Guid AddResourceAssignmentCustomField(
ProjectDataSet prjDs,
Guid assnGuid,
Guid cfMdProp2ndGuid,
int cfMdProp2ndId,
string value)
{
Guid rv = Guid.Empty();
ProjectDataSet.AssignmentCustomFieldsRow assnCfRow =
CreateAssignmentCustomFieldsRow(prjDs, assnGuid, cfMdProp2ndGuid,
cfMdProp2ndId);
if (null != assnCfRow) {
assnCfRow.TEXT_VALUE = value;
assnCfRow.FIELD_TYPE_ENUM = (int)PSLib.CustomField.Type.TEXT;
prjDs.AssignmentCustomFields.AddAssignmentCustomFieldsRow(assnCfRow);
rv = assnCfRow;
}
return rv;
}

Cheers, Albert
 

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