function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Grant270Grant270 

Custom Button Help?

I'm trying to create my first s-control. It's used in a button to update the lead status to dead. My for the control is:

{!URLFOR($Action.Lead.Edit, Lead.Id,[retURL=URLFOR( $Action.Lead.View , Lead.Id ),lead.Status ="Dead", save=1] )}

type is URL.

It is not thowing an error, it just isn't updating the field.  Any reason this shouldn't work?
jrotensteinjrotenstein
Heys, that's pretty neat code! I didn't know you could do that sort of thing.

I played around with it and managed to get it working by referring to the DOM ID of the Status field, rather than the name of "Status":

Code:
{!URLFOR($Action.Lead.Edit, Lead.Id, [retURL=URLFOR($Action.Lead.View, Lead.Id), lea13 ="Dead", save=1] )}

 
How did I know to use lea13? I clicked the Edit button and looked through the HTML source code to find the ID of the pull-down:

Code:
<label for="lea13">Lead Status</label>...<select  id="lea13" name="lea13" tabindex="10">

 I also saw this being used on another developer board post by mtbclimber.

Nice stuff. I'm starting to brim over with ideas of how this type of functionality can be used!

John Rotenstein
Sydney, Australia

TheBootTheBoot

Hi,

I am working on something very similar.  I want to create a button that updates the status on a custom object - Sales Quote to "Sent"

 It is my first S-control - so I am not very knowledgable. 

Here's what I tried:

Code:
{!URLFOR( $Action.Sales_Quote__c.Edit, Sales_Quote__c.Id , [retURL=URLFOR( $Action.Sales_Quote__c.View , Sales_Quote__c.Id), Sales_Quote__c.Status__c ="Sent", save=1] )}

This was just to try it out first, and since I was not using the DOM ID, I didn't expect it to work.  I tried again using the DOM ID for my custom field:

Code:
{!URLFOR( $Action.Sales_Quote__c.Edit, Sales_Quote__c.Id , [retURL=URLFOR( $Action.Sales_Quote__c.View , Sales_Quote__c.Id), 00N50000001p81n="Sent", save=1] )}


But I am not able to save this as an S-control because I get a sytax error telling me that I am missing the field name for my Status field.

Can you please help?!? 

Thanks!!!

-Brandy
 

oscarmackoscarmack

It seems to be a quirk with the URLFOR syntax checking your parameters and if they begin with a number then it assumes it’s some sort of field and tries to resolve it but can’t? If the field begins with a letter like “opp11” (which is the case with standard fields) it doesn’t trigger this quirk so that's why custom fields fail.

The workaround I have is to move the custom field parameter outside the URLFOR formula, e.g.

{!URLFOR($Action.Applicants__c.Edit,Applicants__c.Id,[retURL=URLFOR($Action.Applicants__c.View,Applicants__c.Id),save=1])}&00N50000001eVzV=abc123