Customize Add order based on opportunity Business process

Hi everyone,

I'm looking for a way to customize the Add order based on opportunity BP.

I added some fields to the 'product in opportunity' object, like: discount amount, discount %, semester and schoolyear. Added semester and schoolyear to the product in order object too (discount amount, discount % fields are already exist there).

Now, I want these values to be copied when creating an order from an opp, just like the other fields of the product in order do.

I found this process does the order and creates the products  

https://beable.creatio.com/0/Nui/ViewModule.aspx?vm=SchemaDesigner#process/be82d4e0-4638-4058-975d-050a3dcff8b5

but don't know how to extend the script there (the script that adds the products in on the Adding opportunity products to order  element. 

Is there a way to get to the function that are being executed in that script?

Adding the element's script here.

Thanks in advance,

Chani

if (ProductItems.ToString() != "" || IsCopyAllProduct) {
	var copyProductsOperation = Factories.ClassFactory.Get<
		Terrasoft.Configuration.CopyOrderProductsFromOpportunityOperation>(
		new Factories.ConstructorArgument("userConnection", UserConnection));
	copyProductsOperation.Execute(new Terrasoft.Configuration
		.CopyOrderProductsFromOpportunityOperation
		.CopyOrderProductsArgs {
			OpportunityId = CurrentOpportunity,
			OrderId = NewOrder,
			IsCopyAllProducts = IsCopyAllProduct,
			ProductItems = ProductItems
	});
}
return true;

 

Like 0

Like

5 comments

Hi Chani,

 

You can create your own process and modify the script-task in the way you need or you can copy products from the opportunity to the created order using the "Add data" process element and the sub-process that will receive a collection of OpportunityProduct records.

 

Now step-by-step:

 

1) In the OpportunityOrderUtilities schema there is the CreateOrderFromOpportunity method that is called upon clicking the "New order" button on the opportunity page:

 

this is the code of the button:

and here is the method itself:

As we can see here the method reads the value for the system setting with "CreateOrderFromOpportunityProcess" code. By default the value for this system setting is "Add order based on opportunity":

So we can place any process with the simple start signal there.

 

2) You can either create your own script task in the newly created process (use the code from the original OOB process as an example or paste it and extend in the new process). Or in the new process you can use the collection of records read from the OpportunityProduct object and if the number of records is greater than 1 you can pass this collection to the sub-process that will add data to the created order (the object is OrderProduct).

 

So you need to select one of these two options: either extend the script-task or use the collection of records and a sub-process.

 

Best regards,

Oscar

Oscar Dylan,

Thank you.

But I do want to use the option of selecting products (see pic), how can I have that and get the products list to use in the add data element?

I tried looking in the  Add order based on opportunity BP, but I only see a text parameter for products list.

 

Chani Karel,

 

This is a part of the showProductDialog method of the same OpportunityOrderUtilities module. This will be called regardless of if the process is changed or not. Once products are selected, they are passed to the runProcessCreateOrder method. The list of selected products will be passed as an array of ID's to the process:

 

Best regards,

Oscar

Oscar Dylan,

Thanks

Chani Karel,

Hello Chani i have the same task can you please share with us the solution that you developed for this task. Thank you 

Show all comments