UI action/page - set flag on click, remove flag if ui page is cancelled

LG2
Mega Expert

we have a ui action (button) on a sc_task record which opens a UI page.

within the UI action there are 3 different functions.

within the UI page client script there is the "on OK" function from the html, plus other functions for other things as well (eg for getting values passed to a subsequent client script etc.)

We need to do the following:

1) As soon as the UI Action is clicked (and the dialog page has opened) make the UI action not able to view/click.  This is to prevent accidental submission from multiple users.

(For this we have created a u_modifyflag field which is a true/false and set the UI action condition to only run if the u_modifyflag field is false.   Manually setting the field to true/false has proved this works.)

2)  In the UI page, if the user subsequently clicks Cancel we need the flag to be reset back to "false" (if it is true), so the UI action can be run again if needed.

The UI Page redirects successful submissions to another page, NOT the originating page.

Can anyone suggest where the u_modifyflag can be set from and how?  Also where it would appear within the order of things considering the various functions in each of the scripts.

many thanks

1 ACCEPTED SOLUTION

LG2
Mega Expert

this was solved by adding a second function on the "on click" field of the UI action and then putting that function in the script which disables the UI action:

 

find_real_file.png

In script after end of myFirstFunction:

function my2ndFunction()

 

{

 

  document.getElementById("sys_id of the ui action").disabled = true;

 

}

 

the conditions of the UI action being displayed meant that we did not have to use the flag after all because another value was populated on the successful close of the UI page, so we utilised that field as part of our condition.

View solution in original post

3 REPLIES 3

DirkRedeker
Mega Sage

Hi 

 

Just to clarify.. don't you want to revert the flag in any case, as soon as the UI page is closed?

 

The flag seems to be implemented preventing multiple users opening the record in parallel. 

 

Is that right?

 

BR

Dirk

Hi,

If the UI page is closed by way of cancel the flag should be reverted to "false" (as per item 2), but otherwise the flag should remain 'true' because the action can only be successfully carried out once per task.

(basically it links itself to another record via the UI Page and that relationship is a 1:1).

So the idea is that the 'true' flag will not only prevent two people trying to do the same work simultaneously but also stop it being able to be linked to more than one record.

thx

 

LG2
Mega Expert

this was solved by adding a second function on the "on click" field of the UI action and then putting that function in the script which disables the UI action:

 

find_real_file.png

In script after end of myFirstFunction:

function my2ndFunction()

 

{

 

  document.getElementById("sys_id of the ui action").disabled = true;

 

}

 

the conditions of the UI action being displayed meant that we did not have to use the flag after all because another value was populated on the successful close of the UI page, so we utilised that field as part of our condition.