Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to show in percentage in "Percent complete" feild in servicenow?

Naveen Kumar
Tera Contributor

There is a Field "% Savings" - type = Percent Complete.

 

I calculate the value and set the value to this field.

 

When I try to set its value to 35% , it is just taking 35 .

But I need to display this as 35%.

 

NaveenKumar_0-1694165370415.png

 

 

 

Please guide me in this.

 

Thanks,

Bharath

2 REPLIES 2

Bert_c1
Kilo Patron

Hi,

 

See: Percent Complete Field Type

 

That only works in a list view.

Marco0o1
Tera Sage

Hi @Naveen Kumar  ,

 

I made some testing and I create a HTML element with % simulating the value, there is how to do:

- Create a Client Script On Load for your table:

Marco0o1_0-1694458370097.png

- Make sure you have the "Isolate Script" on false.

- Add the code, replace the "table_name" and "field_name" with your table and field.

function onLoad() {
var table_name = "u_testing_table"; //There is necessary to write the table you are using
var field_name = "u_porcentage"; //There is the field you want to add the %
var inputElement = document.getElementById(table_name+"."+field_name);


var percentPseudoElement = document.createElement("span");
percentPseudoElement.style.fontWeight = "bold"; // Adjust the font weight as needed
percentPseudoElement.style.width = "10px";
percentPseudoElement.textContent = "%";

// Traverse up the DOM tree to the parent's parent of the input element
var parent = inputElement.parentElement;
if (parent) {
parent.style.position = "relative";
parent.style.display = "flex";
parent.style.flexWrap = "nowrap";
parent.appendChild(percentPseudoElement);

}

}

- There is how it look for me:

Marco0o1_1-1694458594993.png

 

You can change the element to other size or colors, but this would work f you only want to visualice, you can combine with the field Percent Complete Field Type to visualice in the list view, and in the form view look the % I suggest.

 

Hope that help you