Get all variables on a task form via script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2016 01:05 PM
Hey all,
I'm trying to do something that may or may not be simple.
Basically, we have mandatory fields on our Catalog Tasks for users to populate. Where we're at however, users will pass tasks between each other or try to assign them before populating the mandatory tasks. The problem we run into is once you go to a task, you can assign and save the record without filling out those mandatory tasks. I'm trying to avoid making a UI policy for every mandatory task we have that says "be non mandatory unless the task state changes to Closed Complete".
So my question is: Is there a way to grab all mandatory variables off a Catalog Task form VIA Client script? Or at least grab all variables regardless of mandatory?
Or even (hopefully?) simpler, is there a way to modify this code to grab all the variables in the map, then check if they are mandatory? If so, set them non mandatory? I've been banging my head against this for awhile and a scalable solution would be perfect so we don't have to create a new UI policy everytime we need a new variable.
function onLoad(){
try{
//Get the 'Variables' section
var ve = $('variable_map').up('table');
//Disable all elements within with a class of 'cat_item_option'
ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference').each(function(elmt){
//CURRENTLY this will make ALL variables read only. I would like something like the following
//if(elmt.mandatory = true){
// g_form.setMandatory(false);
//}
elmt.disabled = true;
});
catch(e){}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 07:08 AM
I understand that part. How are you setting it to mandatory? I believe it is by using UI policies right? Then it will only set mandatory that 2 or 3 fields which you have in that UI policy.