Highlighted
Mark-sai Respected Contributor.
Respected Contributor.
534 views

Apply custom location field meta data in container creation

Jump to solution

Hi,

I am trying to apply custom location field value metadata in container creation via .Net SDK but it is throwing the error '"his additional field must be a location of type Person."'. Below is the sample code. Thanks.

 

FieldDefinitionList udfs = rmRecord.RecordType.UserFields;
UserFieldValue ufVal = null;
foreach (FieldDefinition udf in udfs)
{
if(udf.Format==UserFieldFormats.Object)
{

Location objLoc = new Location(rmDB, fieldValue);
ufVal = new UserFieldValue(objLoc);
}
if (ufVal != null)
{
rmRecord.SetFieldValue(udf, ufVal);
}
}

0 Likes
1 Solution

Accepted Solutions
EWillsey Acclaimed Contributor.
Acclaimed Contributor.

Re: Apply custom location field meta data in container creation

Jump to solution

This code just reads so much better:

rmRecord.SetFieldValue(new FieldDefinition(rmDB, "My field name"), new UserFieldValue(new Location(rmDB, "Location name")));
rmRecord.Save();

But the error is simply saying that the value you've specified is not valid for the field.  This means that the additional field doesn't have "person" enabled.  To correct this you'd go to the Manage ribbon and click Custom Properties.

2017-10-10_17-41-21.png

 Then bring up the properties of the additional field and verify the suitable location types.2017-10-10_17-42-26.png

 

 

That should sort it out for you.

I hope this helps.

 

 

---------
Erik
CMRamble.com
1 Reply
EWillsey Acclaimed Contributor.
Acclaimed Contributor.

Re: Apply custom location field meta data in container creation

Jump to solution

This code just reads so much better:

rmRecord.SetFieldValue(new FieldDefinition(rmDB, "My field name"), new UserFieldValue(new Location(rmDB, "Location name")));
rmRecord.Save();

But the error is simply saying that the value you've specified is not valid for the field.  This means that the additional field doesn't have "person" enabled.  To correct this you'd go to the Manage ribbon and click Custom Properties.

2017-10-10_17-41-21.png

 Then bring up the properties of the additional field and verify the suitable location types.2017-10-10_17-42-26.png

 

 

That should sort it out for you.

I hope this helps.

 

 

---------
Erik
CMRamble.com
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.