Question

Run Process after excel import

Hi Community,

 

We have a case where out costumer will import product lines to a custom Quotes section via excel data import. These products are store in a ProductsInQuotes object that are a detail in the Quotes section

After this import we need to run a process to calculate some total fields that are calculated as a sum of all the records of the ProductsInQuotes in that Quote to update them both in the page and in the DB.

If Products are added manually all is working fine through sandbox messages.

But with excel import we cannot find a trigger that runs immediatly after the import to send the sandbox message.

 

Any ideas on how to achieve this?

Thanks in advance

Luis

Like 1

Like

10 comments

You can see the process used by the excel import in the configuration named "FileImportProcess". It looks like one of the last things it does is writes to the ProcessLog and adds a Reminding record. You could likely create a process that looks for an add signal on Reminding with a caption containing "Import complete". Or it might work to look at the FileImportParameters object for a Stage value of 4 (which means complete), however, not sure if that object will throw a signal - I'd probably try this one first.

Hope this helps.

Ryan

Ryan Farley,

 

Hi Ryan,

 

thanks for the tip. It tried the solution to look for the "FileImportParameters" change to stage 4, but it is not triggering my process for some reason. Any idea why? In a SQL Query I can see that a new record gets added every to FileImportParameters to satge 4 every time I do an import.

Here are the signal parameters:

 

Any idea what I'm missing?

 

Thanks,

Luis

Luis Tinoco Azevedo,

 

In order to resolve the issue please do one of the following steps:

1. Try to use the first approach that was described in the previous post.

2. Please check that the “Signal” start element is executed not in the background mode (the checkbox should be unchecked). Please see the screenshot below:

 

 

Best regards,

Norton

Hi Norton and Ryan,

 

Thanks for the feedback.

We (me and Pedro Pinheiro) went another direction, we overwrote the fileImportWizardStepPage, method setImportSessionInfoParameters because we need to refresh exactly the record of the Quote that we imported the articles to.

 

It is working fine. Our only doubt is if there is the danger of our method being overwritten in the future by a creatio version update.

 

This method is marked as  @protected, bellow print screen:

 

Thanks for any feedback

Luis & Pedro

Luis,

 

Sure, such a solution is appropriate, too. However, you can use this.callParent method to avoid any issues through future updates. Please check the example below:

 

yourNewMethod: function() {
        this.callParent();
        alert("something");
      },

 

Thus, this.callParent calls the parent method firstly instead of re-writing or breaking its logic, so this is a safer approach for a client module schema replacement.

 

Regards, 

Anastasiia

Hi Anastasiia Markina,

 

Thanks for the sugestion, but problem is that the trigger for our method lies inside of the Parent "setImportSessionInfoParameters " so it becomes circular.

The parameters that we need to execute our method is inside of the "setImportSessionInfoParameters", namely the recordId of the quote to which the excel file was imported.

 

Any sugestion how we could make this safer from being overwritten in the future?

thanks

 

Luis,

 

Alas, we are unable to see a screenshot of your custom method. Could you please re-send it as well as provide us with a step-by-step explanation on what method you've written and what parent original client module schema and methods from there you've used?

 

Regards, 

Anastasiia

Hi Anastasiia,

 

1) We created a replacing schema of the "fileImportWizardStepPage"

2) We overwrote the method "setImportSessionInfoParameters"

2.a) We copyed all of the existing logic of this method to the replacing schema

2.b) And inside of the sendRequest method we added our logic.

 

The business case is following:

1) Our costumer will import product lines to a ProductsInQuotes object.

2) The import is done in the a detail of ProductsInQuotes in the Quotes Page

3) After this import is finished we need to run a process to calculate some total fields in the Quote Record that are calculated as a sum of all the records of the ProductsInQuotes. The process needs to have the Quote id parameter to know which Quote record to update and it needs to be triggered imedialty after the file import process is finished.

 

 

I'm inserting the code and hope it is visible now.

 

Thanks for the help

define("FileImportWizardStepPage", ["ProcessModuleUtilities","FileImportServiceRequest"], function(ProcessModuleUtilities) {
    return {
        attributes: {},
        messages: {},
        methods: {
 
            /**
             * Sets import session info parameters.
             * @protected
             * @param {Function} callback Callback function.
             * @param {Object} scope Scope of callback function.
             */
            setImportSessionInfoParameters: function(callback, scope) {
                var isGoogleTagManagerEnabled = this.get("IsGoogleTagManagerEnabled");
                if (!isGoogleTagManagerEnabled) {
                    callback.call(scope);
                    return;
                }
                var importSessionId = this.get("ImportSessionId");
                var config = {
                    contractName: "GetImportSessionInfo",
                    importSessionId: importSessionId
                };
                this.sendRequest(config, function(response) {
 
                    //Check if the imported object is ImdProductsInQuotes and if the import process is over
                    if(response.importObject.name === "ImdProductsInQuotes" && response.totalRowsCount > 0){
 
 
 
                        //Select last record imported
                        var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                            rootSchemaName: "ImdProductsInQuotes",
                        });
 
                        esq.addColumn("Id");
                        esq.addColumn("ImdQuotes");
                        esq.addColumn("CurrencyRate");
 
                        var datecolumn = esq.addColumn("CreatedOn");
                        datecolumn.orderDirection = Terrasoft.OrderDirection.DESC;
 
                        esq.getEntityCollection(function(result) {
                            if (result.success) {
 
                                var first = result.collection.first(); 
 
                                //Get quote code from the last record imported into ImdProductsInQuotes
                                var quoteCode = first.values.ImdQuotes.displayValue;
 
                                window.console.log(quoteCode);
 
                                //Create config to execute Process that refreshes quote record values
                                var config = {
                                    sysProcessName: "Process_caaf7c4", //Process Code
                                    parameters: { 
                                        QuoteCode: quoteCode           //Process Parameter: QuoteCode
                                    }
                                };
                                ProcessModuleUtilities.executeProcess(config);
                            }
                        }, this);
                    }
 
                    this.set("TotalRowsCount", response.totalRowsCount);
                    this.set("ImportObject", response.importObject);
                    callback.call(scope);
                }, this);
            }
        },
        diff: []
    };
});

 

Luis,

 

Thank you for providing is with a clear explanation.

 

If the client module schema was replaced correctly, your custom method will be safe; however, if this was not, the future updates may break its logic. So, please double-check that replacing client module schema was created in accordance with instructions. 

 

Please find the information about it in the article by the link below:

 

https://academy.creatio.com/documents/technic-sdk/7-16/creating-custom-…

 

Regards, 

Anastasiia

Anastasiia Markina,

 

Hi Anastasiia,

 

We created using the instructions on the article so we should be safe, anyhow we will be on the lookout in the next update just to be sure nothing breaks.

 

Thanks,

Luis

Show all comments