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

UI Action Scripting

devr
Kilo Contributor

Hi All

I am trying to write UI Action script for below scenario:

when Demand manager go to an existing   demand that is in draft status and do NOT fill in any/all   of the below fields and click on"Submit demand"   button then there should be an error message that reads "The following mandatory fields are not filled in :   <field name1> , <field name2>":
Business Unit
Primary Queue
Value Driver
Proposed Start Year

I have written UI Action as:

Table: IT Demand [tsp1_demand]

Active: True

Show update: True

Onclick: checkRequired()

Client: True

Condition: current.state==1 && gs.hasRole('demand_manager')

Script:

function checkRequired() {
var bunit = g_form.getValue('u_portfolio_bu');
var pqueue = g_form.getValue('u_primary_queue');
var vdriver = g_form.getValue('u_initiative');
var psuser = g_form.getValue('u_start_year');}
if (bunit == '' && pqueue == '' && vdriver == '' && puser == '') {
g_form.setMandatory('u_portfolio_bu', true);
g_form.setMandatory('u_primary_queue', true);
g_form.setMandatory('u_initiative', true);
g_form.setMandatory('u_start_year', true);
g_form.showFieldMsg('u_portfolio_bu','u_primary_queue','u_initiative', 'u_start_year','is required to submit.', 'error');
}

Above script is not working, user is able to Sumbit demand and there is no error message.

This is the first time I am writing script, please help me in correcting this script.

Thanks and Regards

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

why did you close the function block. before the if condition.



function checkRequired() {


var bunit = g_form.getValue('u_portfolio_bu');


var pqueue = g_form.getValue('u_primary_queue');


var vdriver = g_form.getValue('u_initiative');


var psuser = g_form.getValue('u_start_year');


if (bunit == '' && pqueue == '' && vdriver == '' && puser == '') {


g_form.setMandatory('u_portfolio_bu', true);


g_form.setMandatory('u_primary_queue', true);


g_form.setMandatory('u_initiative', true);


g_form.setMandatory('u_start_year', true);


g_form.showFieldMsg('u_portfolio_bu','u_primary_queue','u_initiative', 'u_start_year','is required to submit.', 'error');


}


gsftSubmit(null, g_form.getFormElement(), '<ui Action action name>');     //please mention your ui action "action name"


}


View solution in original post

6 REPLIES 6

that's why i did not mention the name


Harsh Vardhan
Giga Patron

Hi devr ,



is there any update on this thread? do you need any further help then please let us know.


if your query has resolved please mark the answer correct and close this thread.



How To Mark Answers Correct From Community Inbox