Submit a ticket
Welcome
Login

(Developers only) Changing the implementation logic of passing the products from Dynamics to Oneflow.

If you want to, you can replace the implementation of how we take products/discounts from Dynamics and pass them to Oneflow with your own.


 This is an advanced tutorial for experienced Dynamics CRM Developers. 


So, in order for us to replace the implementation we’ll need to register a plugin step for a ‘of_GetProductsPayload' message : 

It should be synchronous and should execute on PostOperation. 



When the Execute method of your plug-in is called, you’ll get the following input and output parameters: 

Param name

Direction

Data type

Description

requestData

Input

string

JSON string, contains the agreementId in oneflow and opportunityId of the opportunity in Dynamics to take the products from.

isError

Output

bool

indicates whether an error occurred during the oob’s operation

errorMessage

Output

string

Error details if an exception occurred

result

Output

string

resulting JSON string of products to add to the oneflow contract.

Examples: 

requestData format:

{requestData: "{"opportunityId":"E01D4725-8E1D-EA11-A811-000D3AB409EA","contractId":1107536}"}


result format:

[{"products":[{"description":"description of the greatest product","name":"Greatest Product ever","price_1":{"base_amount":"15,00"},"quantity":{"amount":2,"type":"multiple"}},{"description":"Discount for Greatest Product ever","name":"Discount","price_1":{"base_amount":"0.00","discount_amount":"5,00"},"quantity":{"amount":1,"type":"multiple"}},{"description":"Glasses","name":"Glasses","price_1":{"base_amount":"15,00"},"quantity":{"amount":1,"type":"multiple"}},{"description":"","name":"Tax","price_1":{"base_amount":"10,00"},"quantity":{"amount":1,"type":"multiple"}},{"description":"","name":"Discount for the whole order","price_1":{"base_amount":"0.00","discount_amount":"3,95"},"quantity":{"amount":1,"type":"multiple"}}]}]


the payload field contains a JSON that’s passed to Oneflow API directly. 

You can read more about the object structure in Oneflow API docs at https://developer.oneflow.com/docs/product-group 



Now, if you want to have your own implementation of products, you’ll just need to replace the original result json with your own, like so: 

        string requestData = (string)context.ExecutionContext.InputParameters["requestData"];
        string result = (string)context.ExecutionContext.OutputParameters["result"];
        bool isError = (bool)context.ExecutionContext.OutputParameters["isError"];
        string errorMessage = 
        (string)context.ExecutionContext.OutputParameters["errorMessage"];
        
        object oldResultParsed = JSON.Deserialize(result);
        // parse old result and process if needed
        // ... 
        // ... 
        // ...
        // create your own json
        object myResult = .....;
        string myResultJson = JSON.Serialize(myResult);
        context.ExecutionContext.OutputParameters["result"] = myResultJson;


That’s it!


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.