Dear colleguagues

 

I need to run a process when create a new record, in this case invoke it from onEntityInitialized method just in case is a new record or a copy from another (this.isAddMode() || this.isCopyMode())

 

But don't know how to call a process from there, and how to pass parameters, is it possible?

 

Thanks in advance

Like 0

Like

3 comments
Best reply

Hi Julio,

 

You can use this article as a reference on how to trigger the process from the client and pass process parameters to the process.

 

As for calling the process upon creating a new record - onEntityInitialized is not a good choice here since the process call will be triggered once the page is loaded for adding a new record, but not once all the data on the page is specified and the record should be saved. In our case it's better to use save function and overwrite its logic. For example in a following manner:

 

1) We have a UsrTestJSON object which is a section in the system and has UsrTestJSON1Page as an edit page.

 

2) UsrTestJSON object has following columns:

 

UsrTransType - Text (250 characters) data type column

UsrPolicyNumber - Text (500 characters) data type column

UsrTransTime - Time data type column

UsrTransDate - Date data type column

3) We need to call the custom process called "Test JSON page process" with the following schema once the record is saved upon creation:

Please note that the process code is Process_20340ad and the process parameter codes should be the same as process parameter names (as an example please see UsrTransType parameter declaration).

 

4) Add the following code to the UsrTestJSON1Page schema:

define("UsrTestJSON1Page", ["ProcessModuleUtilities"], function(ProcessModuleUtilities) {
	return {
		entitySchemaName: "UsrTestJSON",
		attributes: {},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{
			"Files": {
				"schemaName": "FileDetailV2",
				"entitySchemaName": "UsrTestJSONFile",
				"filter": {
					"masterColumn": "Id",
					"detailColumn": "UsrTestJSON"
				}
			}
		}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			callCustomProcess: function() {
                var usrTransType = this.get("UsrTransType");
				var usrPolicyNumber = this.get("UsrPolicyNumber");
				var usrTransDate = this.get("UsrTransDate");
				var usrTransTime = this.get("UsrTransTime");
                var args = {
                    sysProcessName: "Process_20340ad",
                    parameters: {
                        UsrTransType: usrTransType,
						UsrPolicyNumber: usrPolicyNumber,
						UsrTransDate: usrTransDate,
						UsrTransTime: usrTransTime
                    }
                };
                ProcessModuleUtilities.executeProcess(args);
            },
			save: function(){
				this.callParent(arguments);
				if (this.isAddMode()){
					this.console.log("Adding mode!!!");
					this.callCustomProcess();
				} else if (this.isCopyMode()){
					this.console.log("Copy mode!!!");
				} else if (this.isEditMode()){
					this.console.log("Edit mode!!!");
				} else {
					this.console.log("NOT EDIT, NOT COPY, NOT ADD!!!");
				}
			},
			onUsrTestJSONPageButtonClick: function(){
				this.save();
			}
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[
			{
                "operation": "insert",
                "parentName": "ActionButtonsContainer",
                "propertyName": "items",
                "name": "UsrTestJSONPageButton",
                "values": {
                    itemType: Terrasoft.ViewItemType.BUTTON,
                    caption: { bindTo: "Resources.Strings.UsrTestJSONPageButtonCaption" },
                    click: { bindTo: "onUsrTestJSONPageButtonClick" },
                    "layout": {
                        "column": 1,
                        "row": 6,
                        "colSpan": 1
                    }
                }
            },
			{
				"operation": "insert",
				"name": "UsrTransTypec0a98c8f-acb0-4d1f-9333-94ba13a0abe4",
				"values": {
					"layout": {
						"colSpan": 24,
						"rowSpan": 1,
						"column": 0,
						"row": 0,
						"layoutName": "ProfileContainer"
					},
					"bindTo": "UsrTransType"
				},
				"parentName": "ProfileContainer",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "UsrPolicyNumber9a8b5c79-6a4f-4326-ab8e-d7c471ebc2a5",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 0,
						"row": 0,
						"layoutName": "Header"
					},
					"bindTo": "UsrPolicyNumber"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "UsrTransDate2bfe7bc7-21d7-4024-8809-919959aa5eaa",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 0,
						"row": 1,
						"layoutName": "Header"
					},
					"bindTo": "UsrTransDate"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 1
			},
			{
				"operation": "insert",
				"name": "UsrTransTime7cede060-4f2c-406c-a74f-1abd5679848c",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 12,
						"row": 1,
						"layoutName": "Header"
					},
					"bindTo": "UsrTransTime"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 2
			},
			{
				"operation": "insert",
				"name": "NotesAndFilesTab",
				"values": {
					"caption": {
						"bindTo": "Resources.Strings.NotesAndFilesTabCaption"
					},
					"items": [],
					"order": 0
				},
				"parentName": "Tabs",
				"propertyName": "tabs",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "Files",
				"values": {
					"itemType": 2
				},
				"parentName": "NotesAndFilesTab",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "NotesControlGroup",
				"values": {
					"itemType": 15,
					"caption": {
						"bindTo": "Resources.Strings.NotesGroupCaption"
					},
					"items": []
				},
				"parentName": "NotesAndFilesTab",
				"propertyName": "items",
				"index": 1
			},
			{
				"operation": "insert",
				"name": "Notes",
				"values": {
					"bindTo": "Notes",
					"dataValueType": 1,
					"contentType": 4,
					"layout": {
						"column": 0,
						"row": 0,
						"colSpan": 24
					},
					"labelConfig": {
						"visible": false
					},
					"controlConfig": {
						"imageLoaded": {
							"bindTo": "insertImagesToNotes"
						},
						"images": {
							"bindTo": "NotesImagesCollection"
						}
					}
				},
				"parentName": "NotesControlGroup",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "merge",
				"name": "ESNTab",
				"values": {
					"order": 1
				}
			}
		]/**SCHEMA_DIFF*/
	};
});

So the main idea here is calling callCustomProcess method upon record saving (this.isAddMode()):

save: function(){
				this.callParent(arguments);
				if (this.isAddMode()){
					this.console.log("Adding mode!!!");
					this.callCustomProcess();
				}

And you bind page data to the process using args object parameters:

var args = {
                    sysProcessName: "Process_20340ad",
                    parameters: {
                        UsrTransType: usrTransType,
						UsrPolicyNumber: usrPolicyNumber,
						UsrTransDate: usrTransDate,
						UsrTransTime: usrTransTime
                    }
                };

usrTransType, usrPolicyNumber, usrTransDate and usrTransTime variables are received from the page before saving the record (using this.get method).

 

So you need to develop the logic similar to described above using your own object, process and page schema. As a result the process will return the data specified when creating a new record:

Best regards,

Oscar

Hi Julio,

 

You can use this article as a reference on how to trigger the process from the client and pass process parameters to the process.

 

As for calling the process upon creating a new record - onEntityInitialized is not a good choice here since the process call will be triggered once the page is loaded for adding a new record, but not once all the data on the page is specified and the record should be saved. In our case it's better to use save function and overwrite its logic. For example in a following manner:

 

1) We have a UsrTestJSON object which is a section in the system and has UsrTestJSON1Page as an edit page.

 

2) UsrTestJSON object has following columns:

 

UsrTransType - Text (250 characters) data type column

UsrPolicyNumber - Text (500 characters) data type column

UsrTransTime - Time data type column

UsrTransDate - Date data type column

3) We need to call the custom process called "Test JSON page process" with the following schema once the record is saved upon creation:

Please note that the process code is Process_20340ad and the process parameter codes should be the same as process parameter names (as an example please see UsrTransType parameter declaration).

 

4) Add the following code to the UsrTestJSON1Page schema:

define("UsrTestJSON1Page", ["ProcessModuleUtilities"], function(ProcessModuleUtilities) {
	return {
		entitySchemaName: "UsrTestJSON",
		attributes: {},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{
			"Files": {
				"schemaName": "FileDetailV2",
				"entitySchemaName": "UsrTestJSONFile",
				"filter": {
					"masterColumn": "Id",
					"detailColumn": "UsrTestJSON"
				}
			}
		}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			callCustomProcess: function() {
                var usrTransType = this.get("UsrTransType");
				var usrPolicyNumber = this.get("UsrPolicyNumber");
				var usrTransDate = this.get("UsrTransDate");
				var usrTransTime = this.get("UsrTransTime");
                var args = {
                    sysProcessName: "Process_20340ad",
                    parameters: {
                        UsrTransType: usrTransType,
						UsrPolicyNumber: usrPolicyNumber,
						UsrTransDate: usrTransDate,
						UsrTransTime: usrTransTime
                    }
                };
                ProcessModuleUtilities.executeProcess(args);
            },
			save: function(){
				this.callParent(arguments);
				if (this.isAddMode()){
					this.console.log("Adding mode!!!");
					this.callCustomProcess();
				} else if (this.isCopyMode()){
					this.console.log("Copy mode!!!");
				} else if (this.isEditMode()){
					this.console.log("Edit mode!!!");
				} else {
					this.console.log("NOT EDIT, NOT COPY, NOT ADD!!!");
				}
			},
			onUsrTestJSONPageButtonClick: function(){
				this.save();
			}
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[
			{
                "operation": "insert",
                "parentName": "ActionButtonsContainer",
                "propertyName": "items",
                "name": "UsrTestJSONPageButton",
                "values": {
                    itemType: Terrasoft.ViewItemType.BUTTON,
                    caption: { bindTo: "Resources.Strings.UsrTestJSONPageButtonCaption" },
                    click: { bindTo: "onUsrTestJSONPageButtonClick" },
                    "layout": {
                        "column": 1,
                        "row": 6,
                        "colSpan": 1
                    }
                }
            },
			{
				"operation": "insert",
				"name": "UsrTransTypec0a98c8f-acb0-4d1f-9333-94ba13a0abe4",
				"values": {
					"layout": {
						"colSpan": 24,
						"rowSpan": 1,
						"column": 0,
						"row": 0,
						"layoutName": "ProfileContainer"
					},
					"bindTo": "UsrTransType"
				},
				"parentName": "ProfileContainer",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "UsrPolicyNumber9a8b5c79-6a4f-4326-ab8e-d7c471ebc2a5",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 0,
						"row": 0,
						"layoutName": "Header"
					},
					"bindTo": "UsrPolicyNumber"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "UsrTransDate2bfe7bc7-21d7-4024-8809-919959aa5eaa",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 0,
						"row": 1,
						"layoutName": "Header"
					},
					"bindTo": "UsrTransDate"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 1
			},
			{
				"operation": "insert",
				"name": "UsrTransTime7cede060-4f2c-406c-a74f-1abd5679848c",
				"values": {
					"layout": {
						"colSpan": 12,
						"rowSpan": 1,
						"column": 12,
						"row": 1,
						"layoutName": "Header"
					},
					"bindTo": "UsrTransTime"
				},
				"parentName": "Header",
				"propertyName": "items",
				"index": 2
			},
			{
				"operation": "insert",
				"name": "NotesAndFilesTab",
				"values": {
					"caption": {
						"bindTo": "Resources.Strings.NotesAndFilesTabCaption"
					},
					"items": [],
					"order": 0
				},
				"parentName": "Tabs",
				"propertyName": "tabs",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "Files",
				"values": {
					"itemType": 2
				},
				"parentName": "NotesAndFilesTab",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "NotesControlGroup",
				"values": {
					"itemType": 15,
					"caption": {
						"bindTo": "Resources.Strings.NotesGroupCaption"
					},
					"items": []
				},
				"parentName": "NotesAndFilesTab",
				"propertyName": "items",
				"index": 1
			},
			{
				"operation": "insert",
				"name": "Notes",
				"values": {
					"bindTo": "Notes",
					"dataValueType": 1,
					"contentType": 4,
					"layout": {
						"column": 0,
						"row": 0,
						"colSpan": 24
					},
					"labelConfig": {
						"visible": false
					},
					"controlConfig": {
						"imageLoaded": {
							"bindTo": "insertImagesToNotes"
						},
						"images": {
							"bindTo": "NotesImagesCollection"
						}
					}
				},
				"parentName": "NotesControlGroup",
				"propertyName": "items",
				"index": 0
			},
			{
				"operation": "merge",
				"name": "ESNTab",
				"values": {
					"order": 1
				}
			}
		]/**SCHEMA_DIFF*/
	};
});

So the main idea here is calling callCustomProcess method upon record saving (this.isAddMode()):

save: function(){
				this.callParent(arguments);
				if (this.isAddMode()){
					this.console.log("Adding mode!!!");
					this.callCustomProcess();
				}

And you bind page data to the process using args object parameters:

var args = {
                    sysProcessName: "Process_20340ad",
                    parameters: {
                        UsrTransType: usrTransType,
						UsrPolicyNumber: usrPolicyNumber,
						UsrTransDate: usrTransDate,
						UsrTransTime: usrTransTime
                    }
                };

usrTransType, usrPolicyNumber, usrTransDate and usrTransTime variables are received from the page before saving the record (using this.get method).

 

So you need to develop the logic similar to described above using your own object, process and page schema. As a result the process will return the data specified when creating a new record:

Best regards,

Oscar

Hi Julio,



You can trigger a business process from Client JS code using the ProcessModuleUtilities module. You can inject it as a dependency in a Client schema and call the executeProcess(args) method to call a business process. Business process parameters can be set in the parameters attribute inside the argument you pass to the executeProcess method. Request you to go through this academy link for more information.



If your use case is to trigger a business process 'after' a new record is created, there are a few ways of doing it. You could use the 'Record created' trigger in the Business process designer. Or you can also choose to do it from the service side by listening to entity events on the specific section/object. You can get more details in this academy link.



Thanks,

Shrikanth

M Shrikanth,

Thank you very much

Show all comments

Hi, 

 

Is there a a way to debug business processes in version 7.16.4.1473?

 

I found this but it doesn't work: 

https://academy.creatio.com/documents/technic-sdk/7-13/server-code-debu…

 

I found this too: https://academy.creatio.com/documents/technic-sdk/7-16/overview

But in this case, the business process does not generate a file .cs in the schema folder. 

 

Im using Clio to generate the packages projects, but the cs code of the bps its never generated in the packages. 

 

Looking forward to your comments. 

 

Best regards, 

 

Javier

Like 0

Like

3 comments

Dear Javier,

 

Thank you for your question!

The best way to monitor the Business Process error messages is to turn on the Traces parameter of a particular BP.

But please note that this may impact the system`s performance.

 

You may find these Academy Articles useful:

https://academy.creatio.com/docs/node/1790

https://academy.creatio.com/docs/node/1792

 

In addition, you may turn on the Debug mode of the whole Creatio itself by typing in this string in the browser`s console:

Terrasoft.SysSettings.postPersonalSysSettingsValue("IsDebug", true)

 

But please make sure to turn it off as you are finished as it impacts the system performance.

 

Hope this helps!

 

Regards,

 

Danyil

 

 

Hi Danyil, 

 

Thank you for your response, I know about Traces parameter, but actually I'm trying to debug server side business process' c# code(script task) in visual studio. 

 

Isn't that possible? 

 

Best regards, 

Javier

 

Javier Collazo,

 

Hi Javier,

 

This is only possible using C# interactive tools like dnSpy (can be downloaded from here) where you need to connect to w3wp.exe process of your application pool and debug the logic in real time.

 

As for connecting the app to Visual Studio - you can do it, but this feature was developed to allow development in the File system, but not debugging.

 

Best regards,

Oscar

Show all comments

I have this Action Item and onClick of it, want to trigger a Business Process. How can this be achieved?

 

Thanks

Like 0

Like

2 comments

Dear Anu, 



Can you please specify with more details on how exactly would you like to trigger the process? 



Thank you. 

AnuRoman Brown,



Here is the Academy article to call the BP (Business Process) from the Action items menu.

https://academy.creatio.com/docs/developer/integrations_and_api/busines…

 

Sample,

 

define("AccountPageV2", ["ProcessModuleUtilities"], function(ProcessModuleUtilities) {
    return {
        entitySchemaName: "Account",
        methods: {
            // Проверяет, заполнено ли поле [Основной контакт] страницы.
            isAccountPrimaryContactSet: function() {
                return this.get("PrimaryContact") ? true : false;
            },
            // Переопределение базового виртуального метода, возвращающего коллекцию действий страницы редактирования.
            getActions: function() {
                var actionMenuItems = this.callParent(arguments);
                actionMenuItems.addItem(this.getActionsMenuItem({
                    Type: "Terrasoft.MenuSeparator",
                    Caption: ""
                }));
                actionMenuItems.addItem(this.getActionsMenuItem({
                    "Caption": { bindTo: "Resources.Strings.CallProcessCaption" },
                    "Tag": "callCustomProcess"                
                }));
                return actionMenuItems;
            },
            // call you porcess
            callCustomProcess: function() {
                var contactParameter = this.get("PrimaryContact");
                var args = {
                    // Process name
                    sysProcessName: "UsrCustomProcess",
                    // parameters process
                    parameters: {
                        ProcessSchemaContactParameter: contactParameter.value
                    }
                };
                // run process
                ProcessModuleUtilities.executeProcess(args);
            }
        }
    };
});





BR,

Bhoobalan Palanivelu

Show all comments

Hi,

 

I have a business process where I need to read the read element values in a script task.

When the read element is set to "read a collection of records" I'm using the following code:



var AccountsData = Get>("ReadDataUserTask12.ResultCompositeObjectList");

var AccountData = AccountsData.First();



var AccountAddress="";

AccountData.TryGetValue("Address", out AccountAddress);

 

What change do I need to do when the read element is set to "read the first record"?

 

Thanks,

Raz

 

 

Like 0

Like

3 comments

 

 

 

 

 

 

 

 

string name = string.Empty;
string email = string.Empty;
Guid RecordId = Guid.Empty;
 
/**
 * This approach should not be used in production
 * Please create process parameters and set values with standard tools (i.e. Formula)
 * ReadDataUserTask1 is the Code of "Read One Contact" element
 */
var re = context.Process.FindFlowElementByName("ReadDataUserTask1").GetPropertyValue("ResultEntity");
 
if (re.TryGetPropertyValue("Email", out object _email))
{
	email = _email.ToString();
}
 
if (re.TryGetPropertyValue("Name", out object _name))
{
	name = _name.ToString();
}
 
if (re.TryGetPropertyValue("Id", out object _id))
{
	if(Guid.TryParse(_id.ToString(), out Guid Id))
	{
		RecordId = Id;
	}
}
 
//Set values to process parameters
Set<string>("Name", name);
Set<string>("Email", email);
Set<Guid>("RecordId", RecordId);
 
return true;

 

 

 

Kirill Krylov CPA,

Hi Kirill,

 

I don't understand you code.

So if shouldn't use this code in production.

 

what should I do?

 

I don't manage to get the values from ResultEntry.

 

Thanks,

Raz

Kirill Krylov CPA,

Your code is exactly what I need if I don't want to use "get a set of records" and if I don't what to use the "Formula" process element.

Why not to use it in production?

Show all comments

Dear community,

 

I can't seem to find any documentation about the Active processes / ProcessListeners field that is standard in creatio.

 

Could anyone provide links or an explanation as to how this one is being used?

 

Thank you in advance!

 

 

Kind regards,

Yosef

Like 0

Like

1 comments
Best reply

Hello, Yosef.

 

This is a system field that stores the information about processes Creatio can run when a record is edited or deleted. We do not recommend editing it. If you would like to learn more about the way Creatio uses this field, you should review the TryProcessComplete and ProcessCompleteExecuting methods in the BaseEntity object.

 

Best regards,

Bogdan S.

Hello, Yosef.

 

This is a system field that stores the information about processes Creatio can run when a record is edited or deleted. We do not recommend editing it. If you would like to learn more about the way Creatio uses this field, you should review the TryProcessComplete and ProcessCompleteExecuting methods in the BaseEntity object.

 

Best regards,

Bogdan S.

Show all comments

Hi Community,

On my application I've used the Aspose.PDF connector plugin for Creatio! Then, I created a new printable and set the "Convert to PDF" property true, as you can see in the image below.

 

 

After that, I create a new process in which I am using the plugin process element (Save printable) and in that element I set the parameter "Conver to PDF" to true but the attachment is always saved as a .docx file, regardless of setting of the parameter "Convert to PDF" be true or false.

 

Can you help me solving this issue and explain me why the document saved in the attachments is always in .docx format?

 

Thanks in Advance.

 

Best Regards,

Pedro Pinheiro

Like 3

Like

1 comments

 

Hi Pedro,

 

I apologize for the delay. The [Save printable] element was developed when both .docx and .pdf formats were available out-of-the-box. As such, the "Convert to PDF" parameter is not compatible with the Aspose connector for Creatio. The team in charge does not plan to update this feature in the add-on.

 

However, note that Creatio released the [Process file] business process element to generate custom MS Word or Fast Report reports in version 7.17.2.

Show all comments

There is a Send Email element in the business process sending emails automatically that takes "To:" parameter from some string field.

The string field can contain multiple addresses separated by "; ".

What is the easiest method to send emails to all the listed addresses?

Like 0

Like

2 comments

Hello Yuriy,



You can add multiple emails by clicking the btn_button_preconfigured_new.png button next to the 'To' field in the [Send email] element.  You can add emails from process parameters, lookups, system settings. Please check a screenshot below to see how the selected multiple emails look like in the process element. 



 

Besides, you can find more information about [Send email] process element here: https://academy.creatio.com/docs/user/bpm_tools/process_elements_refere…



Regards,

Kseniia

Kseniia Prokopenko,

If I have a string of multiple addresses, I don't know how many at the time I create the business process , so I can't add + to the TO when I create the business process, Is there a way to add + inside the business process when it runs (like loop over all addresses and add TOs)?

Show all comments

Where can I find documentation on this issue ?

Like 0

Like

3 comments

Hello,

 

If you need to send emails based on the recipient's language, try to add localization to the email template. More info can be found here:

https://academy.creatio.com/docs/user/platform_basics/communications/wo…

 

Regards,

Dean

Dean Parrett,

Thanks Dean, but what I need is to create a user task (activity) connected to case resolution, and its title is the localizable text business parameter I need to create. I have been through lots of academy stuff, but it is not clear to me how to create a localizable text business process parameter.

any clue ?

Hi Ricardo,

 

Do you need to read the case resolution description submitted by a user and use it in the activity, let's say, put it into the activity subject but in different language? 

 

Regards,

Dean

Show all comments

Hello community,

 

We have a use case where some business logic has been implemented as a business process and the output of it is set to 2 business process parameters. We need to trigger this BP from source code and read the output parameters after execution of the process. The execution part is straight forward. The reading of parameters is not. 

 

I went through various articles/questions on the community related to these. But most of them only talk about executing a process by setting parameters and not reading parameters after execution. Request some assistance.



I also went through the IProcessExecutor documentation here and it permits to retrieve one result parameter. What if I need to read more than 1 parameter at the end of the business process execution?? Is there any other way to execute a BP from server side code and get the output parameter?



Note - I am aware that the Business process can be executed via a Http call to the ProcessEngineService and output parameters retrieved via the ResultParameterName query parameter. This is not a viable option for us. Additionally, it only permits one ResultParameterName and not reading multiple business process parameters.

Like 0

Like

4 comments
Best reply

Hello,

 

You can use this example to receive parameters: 

// getting UserConnectionUserConnection userConnection = GetUserConnection();
// getting  IProcessExecutor
IProcessExecutor processExecutor = userConnection.ProcessEngine.ProcessExecutor;
// List of input parameters
var inputParameters = new Dictionary<string, string> {
    ["ProcessSchemaParameter1"] = "Value1",
    ["ProcessSchemaParameter2"] = "Value2"
};
//  List of output parameters
var resultParameterNames = new string[] {
    "ProcessSchemaParameter3",
    "ProcessSchemaParameter4"
};
string processSchemaName = "processSchemaName";
Guid processSchemaUId = Guid.Parse("00000000-0000-0000-0000-000000000000");
 
// Run the process by schema name and forwarding output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaName, resultParameterNames);
// Run the process by schema UId and forwarding output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaUId, resultParameterNames);
 
//  Run the process by schema name with forwarding input and output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaName, inputParameters, resultParameterNames);
// Run the process by schema UId with forwarding input and output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaUId, inputParameters, resultParameterNames);

You can also get values of the resulting parameters by accessing the ResultParameterValues property of the IReadOnlyDictionary <string, object> type of the ProcessDescriptor class: 

ProcessDescriptor processDescriptor = processExecutor.Execute("processSchemaName", inputParameters, resultParameterNames);
object parameter3Value = processDescriptor.ResultParameterValues["ProcessSchemaParameter3"];
if (processDescriptor.ResultParameterValues.TryGetValue("ProcessSchemaParameter4", out object parameter4value)) {
    Console.Log(parameter4value);
}

Please note that such process will always be run in not-background mode and you will be able to receive several parameters only from version 7.17.1. 

 

Best regards,

Angela

Hello,

 

You can use this example to receive parameters: 

// getting UserConnectionUserConnection userConnection = GetUserConnection();
// getting  IProcessExecutor
IProcessExecutor processExecutor = userConnection.ProcessEngine.ProcessExecutor;
// List of input parameters
var inputParameters = new Dictionary&lt;string, string&gt; {
    ["ProcessSchemaParameter1"] = "Value1",
    ["ProcessSchemaParameter2"] = "Value2"
};
//  List of output parameters
var resultParameterNames = new string[] {
    "ProcessSchemaParameter3",
    "ProcessSchemaParameter4"
};
string processSchemaName = "processSchemaName";
Guid processSchemaUId = Guid.Parse("00000000-0000-0000-0000-000000000000");
 
// Run the process by schema name and forwarding output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaName, resultParameterNames);
// Run the process by schema UId and forwarding output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaUId, resultParameterNames);
 
//  Run the process by schema name with forwarding input and output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaName, inputParameters, resultParameterNames);
// Run the process by schema UId with forwarding input and output parameters
ProcessDescriptor processDescriptor = processExecutor.Execute(processSchemaUId, inputParameters, resultParameterNames);

You can also get values of the resulting parameters by accessing the ResultParameterValues property of the IReadOnlyDictionary <string, object> type of the ProcessDescriptor class: 

ProcessDescriptor processDescriptor = processExecutor.Execute("processSchemaName", inputParameters, resultParameterNames);
object parameter3Value = processDescriptor.ResultParameterValues["ProcessSchemaParameter3"];
if (processDescriptor.ResultParameterValues.TryGetValue("ProcessSchemaParameter4", out object parameter4value)) {
    Console.Log(parameter4value);
}

Please note that such process will always be run in not-background mode and you will be able to receive several parameters only from version 7.17.1. 

 

Best regards,

Angela

Angela Reyes,

Thank you Angela for the inputs

Hi not sure whether this thread still seen 

I am using following code 
ProcessDescriptor processDescriptor = processExecutor.Execute("processSchemaName", inputParameters, resultParameterNames); 

While the BP was triggered but i see the InputParameter is null. What i am missing -- any working code. 

            var inputParameters = new Dictionary<string, string> {
                  ["InputParam"] = "Parameter sent from the Virtual Object"
            } ;

           var resultParameterNames = new string[] { "OutPutParam"};
         

           IProcessEngine processEngine = _userConnection.ProcessEngine;
           IProcessExecutor processExecutor = processEngine.ProcessExecutor;


          ProcessDescriptor processDescriptor = processExecutor.Execute("HC_ReadVirtualObject", inputParameters, resultParameterNames);
          object  jsonObj = processDescriptor.ResultParameterValues["OutPutParam"];

 

Sarangarajan Tirucherai,

Hello,

A couple of questions first:

  1. This is only the InputParameter which is null or the OutPutParam as well?
  2. How do you use this InputParameter inside the business process? Do you use it in some formula or simply for filtering or how is it done?

Thank you!

Show all comments

Dear community,

 

I am using the following apps:

Aspose 

'Save Printable' (keep in mind that we tried with a script first but we switched to this for ease of use)

 

Whenever we trigger our business process manually, the pdf gets created automatically. Whenever the BP gets triggered by the portal, the attachment doesn't get converted. We still use the same BP with the same values.

 

Does anyone have any experience with this?

Thank you in advance!

 

Kind regards,

Yosef

Like 0

Like

6 comments

Hi Yosef,

 

Please note that the Aspose connector does not support generating pdf printables when triggered by the portal.

Kindly answer the following questions for the responsible team to further analyze your use-case:

1. What Creatio product and version are you working with?

2. Do you get  a .docx printable generated automatically when the BP is triggered by the portal?

3.  Could you provide us with a BP diagram to have a clearer idea of the use-case?

 

Thank you for your feedback!

Svetlana Kobizka,

 

We actually call the BP through API with a portal user in Creatio.

1. We use Creatio sales, marketing & service / 7.17.1

2. We get a PDF file but we can't open it. Changing it to .docx makes us able to read it as a word file.

3.

this is the initial process: https://prnt.sc/zz2kpg

We call the invoice through API and set it to "Complete". As soon as this happens, we trigger the following flow which is the subprocess: https://prnt.sc/zz2uut

 

Here we have the "save printable" block.

Everything works except when the status is set to complete through the portal API.

 

 

Kind regards,

Yosef

Hi Yosef,

 

Regarding the second issue, we need you to run a check-up and get back to us with the results.



Please set the printables generation to .docx printables in the subprocess in the 'Save printable' element. Run the business process and tell us if a .docx printable is successfully generated when the BP is triggered by the portal.

Alexander Demidov,

 

If we set the processs to docx, everything works. Right now, when we change the generated pdf (through portal) file to ".docx", we can open it in word.

 

Kind regards,

Yosef

I also noticed that we can't generate a pdf in the instance either unless we place an approval block: https://prnt.sc/106hzl7

Without the approval block, the pdf gets created but we're unable to open it unless we manually change it to ".docx" : https://prnt.sc/106i0bb

This process was triggered within Creatio.

 

 

Kind regards,

Yosef

Hi Yosef,

 

Thank you for the clarification. I have submitted this update to the responsible team.

Show all comments