The CreatorCon Call for Content is officially open! Get started here.

How to call Business rule in Ui action?

Ashwini Jadhao
Giga Guru

Hi,

How to fire Business Rule in UI action to create child tables record. After clicking the Ui action The state changes properly but I am not able to fire the BR to Create child tables records.

Once the records get created The another ui action should be visible.

Thank you.

7 REPLIES 7

Hi,

On which form/table, you are creating the UI Action? Are they in the same scope? If not, there might be some scope issue as well?

Try with below code once:

function onClick()
{
 
 if(g_form.getValue('state') != 'add')
 {
 g_form.setValue('state',"add");
 //alert('state changes to add');
 }

 gsftSubmit(null, g_form.getFormElement(), 'createadd');

                          // Make sure "createadd" is the UI Action Name

}

if (typeof window == 'undefined')
 serverAdd();


function serverAdd()
{
 current.state = 'add'; 

 var disc = new GlideRecord('x_256866_outlier_r_add');
 disc.evaluation=current.number;
 disc.state ='new';
 disc.property=current.property; 
 disc.update();

 current.update();
 
 }

Mark Correct/Helpful, if this helps you.

Regards,

Devyani

 

Hi Ash,

If given answer resolves your query, please mark the answer correct, so the question get remove from the unanswered category.

Thanks.

Regards,

Devyani

Saikiran Gudur1
Mega Guru

Fundamentally this question has went in other way and the code too..

 

If you want to fire a Business rule the primary point to check is the Trigger - When?? & Operation? & Condition? (Eg: Before Insert- some x condition)

 

Your UI action code can be written in just two lines without toggling from client to server.

 

if(currrent.state != 'discuss'){

current.state = 'discuss';

current.update();//here as you are invoking a UPDATE operation obviously Update Business Rules defined on that table will run.

}

 

You are using the code which is useful in case if somebody want to have some client side control before handovering to server.

After seeing your code I felt it is not required.

 

The business rule should be Before/After Update with the condition "state CHANGES TO discuss" and you can write the code to insert the child table entries in this BR.

 

Thanks,

Saikiran