Set parent field mandatory when New button clicked on related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 05:19 AM
Hi,
When user clicks New button on incident tasks related list from incident form, then it should abort the user to fill a mandatory field on incident form
Simply, set field mandatory on incident when user clicks on new button in related list.
I tried the below reference(both ui action and script), I can see the message I set but its not setting the field mandatory
Can anyone please help on this issue.
Thanks:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 06:10 AM
Hello @Aruna Sree Yela,
Please try to get value of variable that required to be mandatory using logs and also post images and script here.
Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!
Thank you!!
Dnyaneshwaree Satpute
Tera Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 06:47 AM
Here is the script
function onCondition() {
if (g_form.isNewRecord()) {
var parentRec = g_form.getReference('incident', getParent);
}
}
function getParent(parentRec) {
g_form.addInfoMessage('test message');
g_form.addInfoMessage(parentRec.u_product_model);
g_form.setMandatory('parentRec.u_product_model', true);
}
Output:
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 07:24 AM
Hello @Aruna Sree Yela ,
function onCondition() {
if (g_form.isNewRecord()) {
var parentRec = g_form.getReference('incident', getParent);
}
}
function getParent(parentRec) {
g_form.addInfoMessage('test message');
var product = g_form.getValue('parentRec.u_product_model') ;
var prodModel= setDisplayValue(product); // you can use quote for product and if there is no any need for
setDisplayValue then you can remove this line and add product instead prodModel in setMandatory line.
g_form.addInfoMessage(parentRec.u_product_model);
g_form.setMandatory('prodModel', true);
alert('Please fill mandatory fields');
return false; //Abort submission
}
return true;
Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!
Thank you!!
Dnyaneshwaree Satpute
Tera Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 07:45 AM
Thanks for your time!
No luck, I can see the infomessages and alert on task form but the field on incident is not becoming mandatory.
Thanks