-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM 2015 set statuscode and statecode #84
Comments
@Artemy-Matvienko what is your Dynamics 365/CRM version? If it's 2016 or above, setting the attributes should work. statecode 1 is Inactive, are you sure that your custom statuscode is valid for Inactive state? |
I don't think we've implemented |
@georged Are you suggesting that I extend the Client and SoapRequestGenerator classes to accommodate this extra functionality? I'm assuming the new SoapRequestGenerator function will look something like this: public static function generateSetStateRequest( Entity $entity ) {
/* Generate the Request message */
$requestDOM = new DOMDocument();
$node = $requestDOM->appendChild( $requestDOM->createElementNS( 'http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'SetState' ) );
$node->appendChild( $requestDOM->createElement( 'entityName', $entity->logicalName ) );
$node->appendChild( $requestDOM->createElement( 'id', $entity->ID ) );
$node->appendChild( $requestDOM->createElement( 'statecode', $entity->statecode ) );
$node->appendChild( $requestDOM->createElement( 'statuscode', $entity->statuscode ) );
/* Return the DOMNode */
return $node;
} |
@Artemy-Matvienko yes, you'd need to extend both SoapRequestGenerator and Client. Cheers |
@Artemy-Matvienko Hi, How did you solve the problem? Can you share? |
I'm sharing it in case it might be useful to someone. There is no need to expand classes. The client's executeActions method works. Sample code: $userId = 'xxx';
$state = 0;
$status = -1;
$entity = $this->client->entity( 'systemuser', $userId );
$parameters = [
[
'key' => 'EntityMoniker',
'value' => $entity,
'type' => 'entityreference',
],
[
'key' => 'State',
'value' => intval($state),
'type' => 'state',
],
[
'key' => 'Status',
'value' => intval($status),
'type' => 'status',
],
];
$response = $this->client->executeAction('SetState', $parameters); |
I get the following error
When I try to update with this:
I've come across this similar issue #24, where the solution was to use SetStateRequest. However, I'm not sure how to implement this solution.
Could you please provide an example?
The text was updated successfully, but these errors were encountered: