update Records based on click on Hyperlink

dsf3
Tera Contributor

Hi All,

 

I am having field which has having external Link . Requirement is when ever user click that link it should trigger some script to update records in table.

 

Not sure how I can do that as per my understanding client script will not work here.

 

Let me know if you have any suggestions.

 

 

3 REPLIES 3

Siddhesh Jadhav
Kilo Sage

Hi @dsf3 ,

 

You can achieve this using a UI Macro and UI Page combination.

  • Create a UI Macro and add it to the field using:

    ref_contributions=UI Macro name
    
  • In the UI Macro, render the hyperlink and pass the URL.

  • On click, open a modal dialog (UI Page).

  • In the UI Page, write server-side logic to update the required records.

  • After the update, redirect the user to the external URL if needed.

This approach allows you to safely execute server-side updates when the link is clicked.

 

Thanks and regards,

Siddhesh Jadhav

 

If this resolves your query, please mark this response as Helpful and Accepted.

HI Siddhesh,

Thanks for your response and suggestion. Could you please help with sample code for UI macro. I dont have much idea on UI macro.

Ankur Bawiskar
Tera Patron

@dsf3 

so the field type is URL and it has some link

I don't think clicking that LINK should lead to some database operation and doesn't look like a valid business requirement.

user can click link multiple times leading to multiple updates which is not good for performance

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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