- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 09:01 PM
How to clear the value and how to Mandatory Please help me out
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 10:49 PM
Hello Chandra,
1. With the help of UI Policy and UI Policy Action you can clear the value or set mandatory or Set visibility as well
2.Another option, you can use below scripts:
- clearValue(String fieldName) :Removes any value(s) from the field.
-
setDisplay(String fieldName, Boolean display) :Displays or hides a field.
-
setMandatory(String fieldName, Boolean mandatory)
Makes the specified field mandatory.
Whenever possible, use a UI policy rather than this method.
g_form.setMandatory('field name', true);
g_form.setDisplay('field name', true);
g_form.clearValue('field name');
Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 10:04 PM
Hi Chandra,
Using Client Script:
g_form.clearValue('field_name'); //Syntax for clearing value
g_form.setMandatory('field_name',true); //Syntax for making the field mandatory
Using UI Policy:
Provide the condition in ui policy and Add UI policy action for clearing value of the field and making field mandatory.
In UI Policy Action there you can see the Checkbox for making field mandatory and clear the value of the field.
Using these you can achieve.
Please Mark as correct or helpful..!!
Regards,
Meghnath.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 02:58 AM
Hi Meghnath,
I have written below onload client script.
function onLoad() {
if(g_form.getValue('ca_template') == 'ee299dc2db38c050d71272143996198a'){
//alert('I am here');
g_form.setValue('ca_template',"");
g_form.setMandatory('ca_template', true);
//Type appropriate comment here, and begin script below
}
}
But the problem is if i give sys id CA Template module if i click it takes to schedule job and when we try to execute the new records gets created for different sys id,so my colleague suggested to modify the Transform Script in the transform map the values are taking from their only,but in the transform map where i need to modify.below is the transform map script.
answer = (function transformEntry(source) {
var ch = source.u_ca_template.toString();
var check = new GlideRecord('x_palad_cert_ca_template');
check.addQuery('dn',ch);
check.query();
if (check.next()){
var check1 = check.dn;
}
// Add your code here
return check1; // return the value to be put into the target field
})(source);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 10:49 PM
Hello Chandra,
1. With the help of UI Policy and UI Policy Action you can clear the value or set mandatory or Set visibility as well
2.Another option, you can use below scripts:
- clearValue(String fieldName) :Removes any value(s) from the field.
-
setDisplay(String fieldName, Boolean display) :Displays or hides a field.
-
setMandatory(String fieldName, Boolean mandatory)
Makes the specified field mandatory.
Whenever possible, use a UI policy rather than this method.
g_form.setMandatory('field name', true);
g_form.setDisplay('field name', true);
g_form.clearValue('field name');
Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2019 11:51 PM
But The CA TEMPLATE is the reference field
But if i select another DN i want to show, only for the Undefined DN i want to show blank and mandatory i have written below onload client script but its not working.
function onLoad() {
if(g_form.getValue('ca_template') == ''){
//alert('I am here');
g_form.clearValue('ca_template');
g_form.setMandatory('ca_template', true);
}
}