document.getElementsByTagName is not working in scope application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 04:03 AM
Hi all,
document.getElementsByTagName is not working in scoped application I have written below code in my ui action, I need to change color of my button to green when I click on it.
please let me know what can be done here
function ResolveCall(){
//if(confirm('Are you sure you want to Resolve Call?')){
g_form.setReadonly('priority' , false);
g_form.setMandatory('priority' , true);
g_form.setReadonly('close_notes' , false);
g_form.setMandatory('close_notes' , true);
g_form.setReadOnly('u_process_category' , false);
g_form.setMandatory('u_process_category' , true);
g_form.setReadOnly('u_process_subcategory' , false);
g_form.setMandatory('u_process_subcategory' , true);
g_form.setReadOnly('u_process_activity' , false);
g_form.setMandatory('u_process_activity' , true);
g_form.setValue('u_subject', 'Resolve Call');
// g_form.setReadonly('comments' , true);
alert('asdasd');
var items = document.getElementsByTagName('button');
alert(items+'asd');
for(var i=0;i<items.length;i++)
{
if(items[i].innerHTML.indexOf('Resolve Call') > -1)
{ // Resolve Call is the name of the UI action(not element)
items[i].style.backgroundColor = "#74DF00";
items[i].style.color = "#FFFFFF";
// }
}
}
gsftSubmit(null, g_form.getFormElement(), 'ResolveCall');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 04:32 AM
Hi Anusha,
How to change the button color of a scoped app form in ui16
Please follow link above it has more information about the DOM.
Please like, mark Helpful/Correct based on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 04:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 03:53 PM
This was the key to resolving my issue. Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 05:22 AM
I am putting this note only to state that the above solution requires customization (scripting). This is a classic case of communicating to those making such requirements the following facts BEFORE implementing them:
- This feature is NOT provided out of the box
- There is currently no known configuration to make the system behave this way
- It requires custom code - meaning it is something someone needs to build, document, test, and maintain
- Important: This customization violates best practices and puts you at risk for future upgrades (meaning it can, and likely will break in future releases of ServiceNow.)
If they accept these risks and costs, then you have the option of implementing it - and be sure to document it - very well so someone coming along in 2 years knows what it is, how it was built, what it is supposed to, and how to maintain it.