Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Problem creating inactive record of a custom entity

$
0
0

Hi!

I'm trying to create a new record of a custom entity from a plugin, setting in the new entity object the state and statuscode in this way:

var customEntity = new Entity("new_customentity")

{

["new_name"] = chequePostImage.GetAttributeValue<string>("gval_codcheque"),
["new_cheque"] = chequeRef,
["new_chequeid"] = chequeRef.Id.ToString(),

["statecode"] = new OptionSetValue(1),
["statuscode"] = new OptionSetValue(2)

};

_service.Create(customEntity);

But CRM throw me this error: "2 is not a valid status code for state code new_customentityState.Active on new_customentity with Id a9fc4065-aa41-e911-a955-000d3ac02db8."

I know that I can update the record just after create it, but the plugin must be a sync process and call the server twice (first for create and then for update) may give me low performance. I remember this was posible in previous versions, and I'm not sure if I'm doing something diferent or it can't be done anymore

Any suggestions?

Best Regards!


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>