Remove Decoration

Deepthi13
Tera Expert

Hi team,

I am trying to write script in ui policy with certain conditions, in the part i tried to write remove decoration logic but still it is showing 2 times instead of clearing other one please suggest

function onCondition() {
g_form.removeDecoration('assigned_to','icon-star','Please update the Assigned to with valid user name','color-red');
g_form.hideErrorBox('assigned_to');
if (!g_form.isNewRecord()){
g_form.addDecoration('assigned_to','icon-star','Please update the Assigned to with valid user name','color-red');
g_form.showErrorBox('assigned_to','Please update the Assigned to with valid user name','info');
}

}

find_real_file.png

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Hi Deepthi,

 

Try using something as below.

function onCondition() {
g_form.removeDecoration('assigned_to','icon-star','Please update the Assigned to with valid user name','color-red'); 
g_form.hideErrorBox('assigned_to');
var createdonis=g_form.sys_created_on; 
if (createdonis!='')
{
g_form.addDecoration('assigned_to','icon-star','Please update the Assigned to with valid user name','color-red'); 
g_form.showErrorBox('assigned_to','Please update the Assigned to with valid user name','info');
}
}

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Geoffrey_Bishop
Giga Expert

I was not able to get removeDecoration working when I used a COLOR with my decoration.  Perhaps that is some sort of limitation/bug?

 

	if (! g_form.getValue("cmdb_ci") && !g_form.getValue("business_service")){
		//g_form.addDecoration("cmdb_ci", "icon-star", sDecorationMessage, "color-blue"); //It seems like docorations with COLORS can't later be removed.
		//g_form.addDecoration("business_service", "icon-star", sDecorationMessage, "color-blue");  //Can't later be removed.
		g_form.addDecoration("cmdb_ci", "icon-star", sDecorationMessage); //Works
		g_form.addDecoration("business_service", "icon-star", sDecorationMessage); //Works
	}
	else
	{
		g_form.removeDecoration("cmdb_ci", "icon-star", sDecorationMessage);
		g_form.removeDecoration("business_service", "icon-star", sDecorationMessage);
	}