please provide me below code in clientscript runnable

TanujB
Tera Contributor

(function executeRule(g_form, g_user, g_scratchpad) {
var oldValue = g_form.getOldValue('state');
g_form.showFieldMsg('state', 'Previous state was: ' + oldValue, 'info');
})(g_form, g_user, g_scratchpad);

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @TanujB ,

oldValue? looks like an onChange Client script 

select you tableName and field if it's on table level

 

select catalog name and variable name if on catalog form level

ChaitanyaILCR_1-1752844882375.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   g_form.showFieldMsg('state', 'Previous state was: ' + oldValue, 'info');
   
}

please share your requirement in details (with some screenshots)

if the above doesn't work

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

 

 

Aniket Chavan
Tera Sage
Tera Sage

Hello @TanujB ,

What is your exact requirement? Please provide some more info like you are using it on item level or any table level like INC so that we can have some info for building the script....

Below code you can use for inclident table....

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
       g_form.showFieldMsg('state', 'Previous state was: ' + oldValue, 'info');

   
}

 

AniketChavan_0-1752845090339.png

 

🔹 Please mark Correct if this solves your query, and 👍 Helpful if you found the response valuable.

 

Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024

 

Ankur Bawiskar
Tera Patron
Tera Patron

@TanujB 

what's your business requirement?

Unless you start the development from your side you won't learn it.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader