How can we make BR override OOB UI action message?

Gaurangi Joshi
Tera Contributor

Hi All,

I have a requirement to make comments mandatory while approving the approvals for Knowledge Management Module.
For this functionality, we have created a BR which triggers when:-

GaurangiJoshi_1-1692374316828.png

And this is the script I am using in for setting comments mandatory:-

current.state = 'approved';
if (!gs.nil(current.comments))
current.update();
else {
gs.addErrorMessage(gs.getMessage("Comments are required when approving an approval"));
current.state = 'requested';
current.setAbortAction(true);
action.setRedirectURL(current);
}

And this is working, but we can still see the OOB message alongwith the message I have set when we try to approve without comment from the list view.
How can we override this behaviour?

GaurangiJoshi_2-1692374693627.png

Can someone please guide me on what steps to take to override this default behavior?

 

Thanks in Advance!

Gaurangi

 

 

5 REPLIES 5

Yousaf
Giga Sage

Hi Gaurangi,

Please try using this method

Yousaf_0-1692378571078.png


Mark Correct and Helpful if it helps.


***Mark Correct or Helpful if it helps.***

Hi Yousaf,

I tried doing this but the message is still showing.

current.state = 'approved';
if (!gs.nil(current.comments))
current.update();
else {
gs.flushMessages();
gs.addErrorMessage(gs.getMessage("Comments are required when approving an approval"));
current.state = 'requested';
current.setAbortAction(true);
action.setRedirectURL(current);
}

Can you please check if I am doing it right?
Thanks,

Gaurangi

Kumud Ranjan
Mega Guru

Hi Gaurangi,

 

Use below script :

current.state = 'approved';

gs.flushMessages();
if (!gs.nil(current.comments))
current.update();
else {
gs.addErrorMessage(gs.getMessage("Comments are required when approving an approval"));
current.state = 'requested';
current.setAbortAction(true);
action.setRedirectURL(current);
}

 

Mark answer correct if it helped.

 

Thanks,

Kumud

Hi Kumud,

I tried but it didn't work. ðŸ˜¥