How set the label on the variable for RITM & Catalog task view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2022 09:08 AM
Hi All,
I am working on one catalog item. The requiremnt is to set the label based on the change of the variable .
The code is working fine for catalog view but the code is not working for RITM and Catalog task view .
Please find the working for the catalog item view .
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '') {
// return;
// }
if (isLoading) {
if(newValue == 'outbound'){
var field3 = 'internal_source_host';
var labelElement3 = $('label_' + g_form.getControl(field3).id).select('label')[0].select('span')[1];
labelElement3.innerHTML = 'Internal Source Host (Outbound Firewall Request)'; // Requested By is the label name.
//$('label_' + g_form.getControl(field)).attr("mandatory", "true");
//$("#internal_source_host").attr("mandatory", "true");
// g_form.setMandatory(field,true);
// $('question_help_IO_cf2728036f30dbc05de9f00dba3ee4ef_toggle_value').update('Internal Source Host which will initiate traffic');
var field4 = 'internal_destination_host';
var labelElement4 = $('label_' + g_form.getControl(field4).id).select('label')[0].select('span')[1];
labelElement4.innerHTML = 'Internal Destination Host (Outbound Firewall Request)'; // Requested By is the label name.
//$('question_help_IO_13726afb6f345fc05de9f00dba3ee41e_toggle_value').update('Internal Destination Host which will receive traffic');
var field4a = 'internal_subnet_host';
var labelElement4a = $('label_' + g_form.getControl(field4a).id).select('label')[0].select('span')[1];
labelElement4a.innerHTML = 'Internal Destination Subnet'; // Requested By is the label name.
//$('question_help_IO_2c8f91a1db6f57409189fcfa0c961912_toggle_value').update('Internal Destination Subnet which will receive traffic');
var field6 = 'external_destination_host';
var labelElement6 = $('label_' + g_form.getControl(field6).id).select('label')[0].select('span')[1];
labelElement6.innerHTML = 'External Destination Host'; // Requested By is the label name.
//$('question_help_IO_fc43eafb6f345fc05de9f00dba3ee48f_toggle_value').update('External Destination Host outside CIT Network which will receive traffic');
var field8 = document.getElementById("IO:a8c68c37dbf957002b407d8bbf961960").childNodes;
field8[0].childNodes[0].innerHTML = 'Destination Host is external';
}
}
//Type appropriate comment here, and begin script below
if(newValue == 'inbound'){
var field1 = 'internal_source_host';
var labelElement1 = $('label_' + g_form.getControl(field1).id).select('label')[0].select('span')[1];
// alert(g_form.getControl(field1).id);
// alert(labelElement1);
labelElement1.innerHTML = 'Internal Destination Host(Inbound Firewall Request)'; // Requested By is the label name.
//$('label_' + g_form.getControl(field)).attr("mandatory", "true");
//$("#internal_source_host").attr("mandatory", "true");
// g_form.setMandatory(field,true);
//$('question_help_IO_cf2728036f30dbc05de9f00dba3ee4ef_toggle_value').update('Internal Destination Host which will receive traffic');
var field2 = 'internal_destination_host';
var labelElement2 = $('label_' + g_form.getControl(field2).id).select('label')[0].select('span')[1];
labelElement2.innerHTML = 'Internal Source Host(Inbound Firewall Request)'; // Requested By is the label name.
//$('question_help_IO_13726afb6f345fc05de9f00dba3ee41e_toggle_value').update('Internal Source Host which will initiate traffic');
var field2a = 'internal_subnet_host';
var labelElement2a = $('label_' + g_form.getControl(field2a).id).select('label')[0].select('span')[1];
labelElement2a.innerHTML = 'Internal Source Subnet'; // Requested By is the label name.
//$('question_help_IO_2c8f91a1db6f57409189fcfa0c961912_toggle_value').update('Internal Source Subnet which will initiate traffic');
var field5 = 'external_destination_host';
var labelElement5 = $('label_' + g_form.getControl(field5).id).select('label')[0].select('span')[1];
labelElement5.innerHTML = 'External Source Host'; // Requested By is the label name.
//$('question_help_IO_fc43eafb6f345fc05de9f00dba3ee48f_toggle_value').update('External Source Host outside CIT Network which will initiate traffic');
var field7 = document.getElementById("IO:a8c68c37dbf957002b407d8bbf961960").childNodes;
field7[0].childNodes[0].innerHTML = 'Source Host is external';
}
if(newValue == 'outbound'){
var field3 = 'internal_source_host';
var labelElement3 = $('label_' + g_form.getControl(field3).id).select('label')[0].select('span')[1];
labelElement3.innerHTML = 'Internal Source Host (Outbound Firewall Request)'; // Requested By is the label name.
//$('label_' + g_form.getControl(field)).attr("mandatory", "true");
//$("#internal_source_host").attr("mandatory", "true");
// g_form.setMandatory(field,true);
// $('question_help_IO_cf2728036f30dbc05de9f00dba3ee4ef_toggle_value').update('Internal Source Host which will initiate traffic');
var field4 = 'internal_destination_host';
var labelElement4 = $('label_' + g_form.getControl(field4).id).select('label')[0].select('span')[1];
labelElement4.innerHTML = 'Internal Destination Host (Outbound Firewall Request)'; // Requested By is the label name.
//$('question_help_IO_13726afb6f345fc05de9f00dba3ee41e_toggle_value').update('Internal Destination Host which will receive traffic');
var field4a = 'internal_subnet_host';
var labelElement4a = $('label_' + g_form.getControl(field4a).id).select('label')[0].select('span')[1];
labelElement4a.innerHTML = 'Internal Destination Subnet'; // Requested By is the label name.
//$('question_help_IO_2c8f91a1db6f57409189fcfa0c961912_toggle_value').update('Internal Destination Subnet which will receive traffic');
var field6 = 'external_destination_host';
var labelElement6 = $('label_' + g_form.getControl(field6).id).select('label')[0].select('span')[1];
labelElement6.innerHTML = 'External Destination Host'; // Requested By is the label name.
//$('question_help_IO_fc43eafb6f345fc05de9f00dba3ee48f_toggle_value').update('External Destination Host outside CIT Network which will receive traffic');
var field8 = document.getElementById("IO:a8c68c37dbf957002b407d8bbf961960").childNodes;
field8[0].childNodes[0].innerHTML = 'Destination Host is external';
}
}
The above code is working for Catalog View . As per the screenshot . Working fine when ordering the item.
Once the order is submiited . it is not coming as excepted .
Now the isssue : As per the above code . I am running oNchange Client scripts which is running on selecting the Applies to Catalog Item View .
SO as per the screenshot , I tried trouble shooting based on selcting All the three Applies to Catalog Item View ,and the other two. Please find the screenhot below :
But on selecting the above three options I got error as onChange script error: TypeError: Cannot read properties of undefined (reading 'id') function . Please find the scrrenhot :
Please help me with the correct syntax for the running it on RITM View & Catalog task view . I Tried many thing but not working.
@Ankur Bawiskar and other experts.