Hi. 

 

Im trying to save a script task in the open process of a lookup but when I try to save it the next message appear: An item with the same key has already been added

 

And i can´t save the process. I already  generate all schemas and compile. But i still have the same problem 

 

 

Do you have any idea why is this happening? 

 

Thank you 

 

 

 

Like 0

Like

1 comments

Hello!
I recommend checking the application logs for error details. Based on them, we can decide on the next steps.

Show all comments

I am trying to add a filter on the lookup owner based on the account field, but the filter is not working. Does anyone have an idea why?

Thanks!

handlers: /**SCHEMA_HANDLERS*/[
        {
            request: "crt.LoadDataRequest",
            handler: async (request, next) => {
                // filter the contact lookup for the account
                             
                if(request.dataSourceName !== "LookupAttribute_85sj3qr_List_DS") {
                    return await next?.handle(request);
                }
         
                // get the account                  
                const account = await request.$context.Parameter_q8l08xk;
                if (account) {
                    const filter = new sdk.FilterGroup();
                    await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", account.value);
         
                    
                    const newFilter = Object.assign({}, filter);
                    newFilter.items = filter.items;
         
                    request.parameters.push({
                        type: "filter",
                        value: newFilter
                    });
                }
                             
                return await next?.handle(request);
            }
        }
            
        ]/**SCHEMA_HANDLERS*/,

Like 0

Like

2 comments

First, enable debug mode by executing the following in the browser console:

See https://customerfx.com/article/debugging-client-side-code-in-creatio-fo…

Once enabled, open the code for the page and set some breakpoints. Is a dataSourceName for "LookupAttribute_85sj3qr_List_DS" getting triggered? Maybe the name is wrong?

Is request.$context.Parameter_q8l08xk correctly retrieving the account?

Ryan

Everything looks Correct , and the issue was that I forgot to add the SDK "@creatio-devkit/common" to the page .
Thank You 

Show all comments

Hello,

 

I need to call a code once a record gets created for the first time. This worked using the following:

handlers: /**SCHEMA_HANDLERS*/[
			{
        request: "crt.SaveRecordRequest",
        handler: async (request, next) => {

 

however what this does is execute the code for each attribute value change, which is not what is needed. How can I call this exactly once just when the record is created for the first time and that's it, without having to call it again for each save request? Thanks

 

Note: I have tried replacing SaveRecordRequest with CreateRecordRequest, however the code was not executed once saving, or on any save.

 

Best,

Mohamad

Like 0

Like

10 comments

You can use the CardState to see if the record is in add mode (record is being added, saved for first time) or edit mode:

const mode = await request.$context.CardMode;
if (mode === “add”) {
    //
}

If you need to call some code exactly once when a record is created, I'd suggest moving the whole logic to backend. Specifically EntityEventListener and implement OnInserting or OnInserted methods to call your logic before or after the record is saved

Ryan Farley,

Hey Ryan,

 

Thanks for the reply, however that didn't work. The CardMode returns undefined, and when inspecting it in developer tools (request.$context object) the value is always 'edit' , when inserting the first time or when updating. Is there anything else I can do to fix the issue? Thanks

 

Best,

Mohamad

Yurii Sokil,

Hey Yurii,

 

Thanks for the reply, I have tried moving the logic to backend, however I encountered some issues. The overloaded method OnInserted cannot be async, and therefore I cannot call APIs directly from that method.

There is another option to call asynchronously using this method https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/back-end-development/objects-business-logic#title-2173-11 . However that doesn't solve the problem as if there were any errors when executing the asynchronous code, the record gets saved normally without indicating errors. Its a fire and forget operation and I need something that prevents a record from being inserted if the API call failed. Is there any way I can achieve this? Thanks for help

 

Best,

Mohamad

Mohamad Salhani,

If all you're after is to set up an auto number column, you can use the new auto number column default value. See https://customerfx.com/article/working-with-autonumber-fields-in-creatio/

Ryan

Ryan Farley,

No, so basically I need to populate a field once a record is created, and the value comes from an external API that I have to call

Ryan Farley,

Thanks for the support, I was finally able to solve it by checking the createdOn and modifiedOn dates for the record and see if they are equal, this way I can identify if the record was added for the first time or not. 

Thanks again!

Hi Mohamad, 
You can use AsyncPump.Run() to call async methods synchronously in your event listener. Also you can override OnInserting rather than OnInserted so your logic is called before the record is actually saved. 

Yurii Sokil,

Hey Yuri,

 

Thanks for the reply! It did work however I have a question. How can I pass arguments to the method passed in AsyncPump.Run() ? 

I have this code, but I can't pass arguments to the method.

 

[EntityEventListener(SchemaName = "UsrPetolTest")]
public class CustomEntityEventListener : BaseEntityEventListener
{
    public override void OnInserting(object sender, EntityBeforeEventArgs e)
    {
        base.OnInserting(sender, e);
 
        var entity = (Entity)sender;
        var userConnection = entity.UserConnection;
 
        AsyncPump.Run(testing);
 
    }
 
    private async void testing()
    {
        try
        {

 

Best,

Mohamad

Show all comments

Hi community, 

Where can I find the source code responsible for this checkbox (Make the list editable). 

I want to make this detail editable only in one section. Here is my use case : I'm using this detail in two sections A and B. In section A, I want the detail to be editable like this : 

 

But in section B, I don't want this behavior (checkbox must be unchecked) like this : 

Like 0

Like

4 comments

You should create 2 separate details. And add them to the separate edit page for section A and for section B.

Thanks Antonii, isn't there any other way than creating two details ? 

Ismail el lahya,

This is the best way to perform this task

Antonii Viazovskyi,

Thank you!

Show all comments

Hello, I added a new page on BP and open it using a pre-configured page element.



As a data source of the UI page, I use the Contact entity, but I can't specify or send the data source record to the element.

There is no option for that.



I can't use any BR logic as well.



Like 2

Like

1 comments

Hello,

 

From the configured 8x page, you can pass parameter values to the process. In this case, in the Member.

Show all comments

Good day, Colleagues!

Does anyone possibly have a code example on the new Freedom page showing how to calculate the difference of values ​​of two page fields and write it into a third field? For example: payment balance = Amount-PaymentAmount Maybe there's also a code example on how to get the exchange rate on the date specified in the Date field according to the Currency field or an example of how to refer to another object to get a value from it.

Like 2

Like

3 comments

You can see how to wire up a code to respond to a field change here:

https://customerfx.com/article/responding-to-an-event-when-a-field-is-c…

As far as getting and setting the values, this article will show you how to do that: 

https://customerfx.com/article/reading-and-setting-field-values-via-cod…

Ryan

Ryan Farley,



Thank you, I will give it a try.

Ryan Farley,

 

How can I achieve the same requiremet, but for the fields that are inside a detail with editable list?

 

Thank you in advance.

 

Best Regards,

Pedro Pinheiro

 

 

Show all comments

Hey,

I've been searching, but I can't seem to find the function I want to override, it's the function that creates the "Run Process" button on the section page.

 

I want to disable it to users who aren't the Supervisor.

I've done something similar with the getViewOptions function so that only the Supervisor could change the column layout of the different sections.

 

Any help in finding the function I need to override would be appreciated!

 

Thanks in advance! 😁

Like 0

Like

2 comments
Best reply

Hi Edo,

I've not tested this yet, but wanted to mention for you to try. That button does have an attribute that controls its visibility. The attribute is "IsProcessButtonVisible". The attribute, and populating of the menu items is done in the mixin "ProcessEntryPointUtilities". You can override the function "fillRunProcessButtonMenu" on BasePageV2 (or which ever specific page you want to do this on). Something like this: 

fillRunProcessButtonMenu: function() {
    if (UserIsSupervisor) {
        // call base function to populate menu and set visible
        this.mixins.ProcessEntryPointUtilities.fillRunProcessButtonMenu.apply(this, arguments);
    }
    else {
        // do nothing except ensure button not visible
        this.set("IsProcessButtonVisible", false);
    }
}

Again, I've not tested that, but I believe it would work.

Ryan

Hi Edo,

I've not tested this yet, but wanted to mention for you to try. That button does have an attribute that controls its visibility. The attribute is "IsProcessButtonVisible". The attribute, and populating of the menu items is done in the mixin "ProcessEntryPointUtilities". You can override the function "fillRunProcessButtonMenu" on BasePageV2 (or which ever specific page you want to do this on). Something like this: 

fillRunProcessButtonMenu: function() {
    if (UserIsSupervisor) {
        // call base function to populate menu and set visible
        this.mixins.ProcessEntryPointUtilities.fillRunProcessButtonMenu.apply(this, arguments);
    }
    else {
        // do nothing except ensure button not visible
        this.set("IsProcessButtonVisible", false);
    }
}

Again, I've not tested that, but I believe it would work.

Ryan

Ryan Farley,

Thank you very much!

This is exactly what I was looking for and is working great 😁

Show all comments

Hello!

 

I want to add a pop-up whenever a process starts. For example, I have a process that deleted an opportunity. This will open another process. Through code, I want the pop-up to appear when that second process starts or ends.

 

Does anybody know how I can do this?

 

Thank you!

Like 0

Like

3 comments

Dear Diana,

 

Thanks for your question.

 

 

To have a pop-up windows element in business processes you can use the following marketplace solution: 

https://marketplace.creatio.com/template/popup-element-business-process…

 

Hope this recommendation is helpful to you!

 

Best regards,

Anastasiia

Hi!

 

This add-on doesn't work, that's why I want to add the pop-up through code

Ghiu Diana Stefania,

 

You can refer the following article to understand the logic of how to send websocket message from a process script task and receive the message on the client side.

 

Add message publication logic through WebSocket

 

Hope this helps.

 

Regards,

Sourav

 

Show all comments

Hi!

 

Does anybody know how I can create a function, in Lead Page for example, that will start a process?

 

Thank you!

Like 0

Like

3 comments

Hello,

 

Can you please give us more details on what logic exactly you are trying to achieve?

 

Best regards,

Mira

Mira Dmitruk,

Hi!

 

I created a custom button on the Lead page. In the Lead I had a process that runs manually when pressing the "Run Process" button. I want to move this process to start when clicking my custom button.

 

I tried to use this but it doesn't do anything:

 

onOpenGroupSearchClick: function() {

                //this.showInformationDialog();

                

                var args = {

                    // The name of the process that needs to be launched.

                    sysProcessName: "LeadGroupSearch"

                };

                // Launch of the custom business process.

                ProcessModuleUtilities.executeProcess(args);

            },

 

But clicking the button works. You can see that I added a pop-up and it appears. The problem is that the process doesn't start.

 

In the "Run Process" I have to start the process when the LeadId is read. Should I add this to the code?

 

Thank you!

Ghiu Diana Stefania,

This article shows how to start a process from client-side code: 

https://customerfx.com/article/programmatically-starting-a-process-from…

Ryan

Show all comments

Hello!

 

I have a process that needs to check the value of a field. If the value is correct, another field will be unlocked, if it is not, a popup will appear.

 

The problem is that sometimes the pop-up appears before the page gets refreshed. I have the "Refresh active page" add-on inserted in the process that updates that field.

 

I think sometimes the pop-up is quicker than the refresh. The pop-up has been implemented by code. 

 

Thank you!

Like 0

Like

1 comments
Best reply

Hello Diana,

 

As a suggestion you can add a timer after the "Refresh active page" element, and set it to two seconds for example.

This way you could ensure that the element is completly executed in the background and only then the pop-up is displayed.

 

 

This add-on was developed by a third party, so if you would like to receive assistance regarding how does it work in detail, please contact  info@solutionsmetrix.com . Unfortunately we can not ensure how will behave the business process with third party custom developments.

 

Best regards,

Dariy

Hello Diana,

 

As a suggestion you can add a timer after the "Refresh active page" element, and set it to two seconds for example.

This way you could ensure that the element is completly executed in the background and only then the pop-up is displayed.

 

 

This add-on was developed by a third party, so if you would like to receive assistance regarding how does it work in detail, please contact  info@solutionsmetrix.com . Unfortunately we can not ensure how will behave the business process with third party custom developments.

 

Best regards,

Dariy

Show all comments