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

(Batch) Activate or Close Quotes #17

Open
zaha opened this issue Aug 19, 2019 · 3 comments
Open

(Batch) Activate or Close Quotes #17

zaha opened this issue Aug 19, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@zaha
Copy link
Contributor

zaha commented Aug 19, 2019

Hi @RafaelCavazza

I tried to activate and close a quote, but I always get the following error:

[19.08.2019 11:45:05] System.Private.CoreLib: Exception while executing function: CloseNeglectedOpportunitiesAsLost. Xrm.Crm.WebApi: Error occurred and no handler is available for content in the multipart/mixed format.

Am I doing somethring wrong here?

var batchRequest = new BatchRequest();

foreach (Guid quoteId in currentBatch)
{
	var activateQuote = new Entity("quote", quoteId);
	activateQuote["statecode"] = (int)QuoteState.Active;
	activateQuote["statuscode"] = (int)Quote_StatusCode.InProgress_Active;
	
	batchRequest.AddRequest(new UpdateRequest(activateQuote));
}

BatchRequestResponse response = await webApi.ExecuteBatchRequestAsync(batchRequest);

Or is this operation not supported yet? I am not quite sure how this is supposed to work with the Web API. I found one source stating that you are supposed to use the Update Request for that kind of operation now and then I found special actions just for Win Quote and Revise Quote in the Web API doc.

Would need to know the same for winning/losing opportunities, but I assume this is similar.

@RafaelCavazza
Copy link
Owner

Hi @zaha,

Some native entities have special actions to change their state.
I belive quote is one of them:
Winquote, CloseQuote

I'll implement the Winquote and CloseQuote actions in the api.

The bulk actions are a little more complex to implement and I would like to review the way they are implemented before adding more custom actions.

But if bulk 'Close Quote'/'WinQuote' are a must-have for you scenario I can do it first.

@zaha
Copy link
Contributor Author

zaha commented Aug 29, 2019

Hi @RafaelCavazza,

as I had some time on my hand I already started on it myself. I figured it would be a good idea to give the way custom actions are handled an overhaul to make it similar to the official SDK's Organization Service:

I planned to have a marker Interface for all actions IWebApiAction and a general method like WebApi.Execute(IWebApiAction action) with which all actions can be executed. This will make it easier to extend in the future and doesn't crowd the interface with a special method for every action.

While doing so I also realized it would be nicer to rely on a custom Contract Resolver and JSON Converter to handle special serialization rules like for Entity References or Activity Parties to keep the Execute method simple. When I'm done it should be possible to simply call JsonConvert.SerializeObject(action); and get the valid ODATA json out of it for all actions like close incident, qualify lead or the newly implemented close/win quote/opportunity.

I'm right now in the middle of implementing this so if you have other ideas just say them, so I can consider them in the implementation. :)

@RafaelCavazza RafaelCavazza added the enhancement New feature or request label Aug 29, 2019
@RafaelCavazza
Copy link
Owner

RafaelCavazza commented Aug 29, 2019

Since we only added what we needed a lot of custom actions are not covered.
It makes a lot of sense to separate them.

The custom Json converter is a great idea to organize and separate the serialize logic. I think we can creat a separate issue for this one.

I'll wait you PR and perhaps we can start to cover other custom actions.

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

No branches or pull requests

2 participants