CSOM: can't create new Resource

Copper Contributor

Hi everybody.

 

I'm currently struggling with CSOM because I get this error when trying to create a new Enterprise Resource in my context:

 

"PJClientCallableException: CustomFieldRequiredValueNotProvided\r\nCustomFieldRequiredValueNotProvided\r\nmdpropuid = 6838a952-53df-e711-80dd-00155d0c8a0e"

 

I am setting the value for that custom field, but it doesn't seem to be accepting it.

 

This is my code:

 

EnterpriseResourceCreationInformation resourceInfo = new EnterpriseResourceCreationInformation();
resourceInfo.Name = name;
resourceInfo.Id = Guid.NewGuid();

context.EnterpriseResources.Add(resourceInfo);

context.EnterpriseResources.GetByGuid(resourceInfo.Id).FieldValues.Add(properties.keyLegajo, legajo);

System.String[] list = { properties.keyHorarioTrabajoFull };

context.EnterpriseResources.GetByGuid(resourceInfo.Id).FieldValues.Add(properties.keyHorarioTrabajo, list);

context.EnterpriseResources.Update();
context.ExecuteQuery();

 

 

I'm setting the field value with a key like "Entry_entryIdHere", because this custom field has a LookUp Table.

 

When I set the field as not required, this works fine and the other custom field I'm setting is correctly settled.

 

I hope someone can help.

 

Thanks!

3 Replies

I have something on the technet gallery that may help: https://gallery.technet.microsoft.com/Custom-and-Native-field-29cb2e42?redir=0 but it's about projects, not resources... but the examples for fieldvalues are supposed to be similar.

 

Interesting you say it works for a different custom field but not this one. What happens if you make this one unrequired, and make the one that has been working that's unrequired now required?

 

Have you tried passing the value as an array, even if there's only one entry in the array?

sorry, totally see your "list" now.

Hello Ian, thanks for your help, I'll dig into the content you shared. Sadly, it hasn't helped until now.

 

You're right when you suggest changing the "required" attribute of the fields, doing that does change the situation. I'm working with two fields, one of them an Integer and the other one (the one that causes trouble) a text field with a LookUp Table. When I set the problematic field as "not required", the resource is created correctly and the field takes the default value instead of the one I'm theoretically setting, so I believe there's a problem with the way I'm setting it. Which looks weird is that, given that it takes the default value when it's not set as required, it'd be expectable that it'd do the same thing when set as required too, allowing the creation, but instead it fails.

 

However, I'll keep searching and taking a look at what you shared.

 

Thanks.