This topic contains 4 replies, has 0 voices, and was last updated by pcutler 7 years, 1 month ago.
-
AuthorPosts
-
September 18, 2017 at 1:33 pm #21401
mushrushI need a piece of script to fire off when a Role change is made to a contact record. Is it possible to detect this role change? I cannot get the User Event script or the Client script to fire off when a user updates the primary contact or changes the role at all. Does anyone have any ideas or suggestions? Right now I am having the user change the name, save, then change the name back, then save again to get the script to trigger after they make the role change.
Thanks!
This is a cached copy. Click here to see the original post. -
September 20, 2017 at 3:44 pm #21402
pcutlerI haven't tested this, but assuming you're right and no user event scripts fire when the contact role is changed how about this:
A user event script that hides the "Update Primary" button on the contacts sublist and creates a new custom "Update Primary" button.
A client script that opens a suitelet popup when clicking the custom "Update Primary" button.
A suitelet that replicates the behavior of the native functionality and triggers your custom logic.
Ordinarily I'd recommend against replicating native NetSuite functionality, but the update primary screen is so trivial that this seems like a reasonable work-around.
-
September 21, 2017 at 7:29 am #21403
mushrushpcutler thank you for your response and idea. I am not sure it will work as I do not believe we have access to edit the contact role field on the sublist of the customer record. Nor do we have access to the role field from the contact record. Not sure how to go about creating a workaround.
All I need to do is have the ability to detect the change and fire off my already created script….
-
September 21, 2017 at 8:53 am #21404
khultquistYou might have to use a scheduled script and suffer the 15 minute lag.
-
September 21, 2017 at 4:54 pm #21405
pcutlermushrush Your request is simple, but unfortunately NetSuite doesn't run any triggers in that context, so the solution is more complicated.
Here's my suggestion in code, deployed as a user event script on the customer record. khultquist has a good suggestion too if you're ok with waiting for a scheduled script to run.
Code:
function beforeCustomerLoad(type, form, request)
{
if(form)
{
// get the contact sublist
var sublist = form.getSubList('contact');
if(sublist)
{
// get the update contact button
var btn = sublist.getButton('updatecontact');
if(btn)
{
// hide the update contact button
btn.setVisible(false);// add our own custom button instead
var customBtn = sublist.addButton('custpage_update_contact_role', 'Update Contact Role', '(' + myClientScript.toString().replace(/"/g, "'") + ')()');
}
}
}function myClientScript()
{
// update the contact role in a way that you can do a better job keeping track of
alert('hello world');
}
} -
AuthorPosts
You must be logged in to reply to this topic.