Skip to content
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

Open
Artemy-Matvienko opened this issue Apr 11, 2019 · 5 comments
Open

CRM 2015 set statuscode and statecode #84

Artemy-Matvienko opened this issue Apr 11, 2019 · 5 comments

Comments

@Artemy-Matvienko
Copy link

Artemy-Matvienko commented Apr 11, 2019

I get the following error

Property statecode of the new_test entity cannot be set in /var/www/html/Sources/vendor/alexacrm/php-crm-toolkit/src/Entity.php on line 271

When I try to update with this:

$test->statecode = 1;
$test->statuscode = 100000000;

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?

@georged
Copy link
Contributor

georged commented Apr 11, 2019

@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?

@georged
Copy link
Contributor

georged commented Apr 11, 2019

I don't think we've implemented SetStateRequest.
Check SoapRequestGenerator and follow the existing methods style to create new request for SetState. Then call it as we do in Client.php, e.g. see delete method.
If you don't want to write any php, you can try creating custom action in CRM and then call executeAction.

@Artemy-Matvienko
Copy link
Author

Artemy-Matvienko commented Apr 12, 2019

@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;
}

@georged
Copy link
Contributor

georged commented Apr 14, 2019

@Artemy-Matvienko yes, you'd need to extend both SoapRequestGenerator and Client.
If you fancy the pull request, we can test it and incorporate into the toolkit.

Cheers
George

@aliihsan
Copy link

aliihsan commented Jun 6, 2024

@Artemy-Matvienko Hi, How did you solve the problem? Can you share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants