You need to sign in to do that
Don't have an account?
Nordberg
Change Lead owner Via S-Control
I need to change the Lead owner via an S-Control after the new lead is
saved. The owner will be changed to the value of a custom field that
is a lookup field to the user table.
Any help would be appreciated,
Thanks,
JD
Any help would be appreciated,
Thanks,
JD
Code: Note that this code assumes the field name is "NewOwner", which the merge field will add "ID" to for lookup fields, hence "NewOwnerId__c". Hope this helps you out.
~ sfdcfox ~
Error: Function REQUIRESCRIPT may not be used in this type of formula
I am obvioulsy new to this type of work and any help would be greatly appreciated.
Thanks,
JD
Code: The format I provided before would be for an OnClick button/link.
Thanks,
JD:smileyvery-happy:
Code:
The code inside the {! ... } section will be evaluated and replaced inline within the code. Basically, the resulting code would look like:
if(true)
If the owner does not equal the selected ID. Otherwise, it would look like:
if(false)
This, of course, means the code would not evaluate; no API call would be used and the page would not refresh. Also, I changed the page refresh so if there's an error then the page won't refresh until they leave the lead and come back to the record.
~ sfdcfox ~
I really do appreciate all of your time and effort.
Thanks,
JD
The effect is that the browser never sees this conditional statement; it will see if(true) or if(false) and then execute the code to change the owner (or not). This same logic could be written as:
if("{!Lead.OwnerId}" != "{!Lead.NewOwnerId}")
You can use that as a replacement to the original "if" line if it makes more sense to you.
To send an email notification, you need to "check the notification checkbox". In the AJAX toolkit, this is done by including the appropriate header; you should add these two lines of code:
sforce.connection.emailHeader = {}
sforce.connection.emailHeader.triggerUserEmail = true
This will tell the API that it should send the default notification email. You may want to refer to the API and AJAX Toolkit documentation for more information.
~ sfdcfox ~
Thanks,
JD