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
Dan_CDan_C 

Error Message with Scontrol

My end goal with this project was to make some lead fields required to convert but not required just to save the record. Maybe I'm going about this all wrong and you guys might have a better solution for me, but right now I'm looking to find a way to create a standard looking salesforce error message with an scontrol. Right now I am using alert boxes and just redirecting back to the lead. This isnt good enough.

 

I went the way of the ever so increasingly outdated scontrol because we already have one in place that auto populates fields on convert (our logic is more complicated than the simple sfdc mapping).

 

Any help that you could offer

 

Thanks

 

Dan

jkucerajkucera

I can't help you with the sControl, but Apex Lead Convert lets you run triggers on the act of conversion that could be used for this sort of validation.

 

If you don't have Apex Lead Convert, you can submit a case to support to turn it on for you.

Dan_CDan_C

 

Hey

 

 

Can you elaborate on that please? I was under the impression that the ‘Validation/Triggers on Lead Convert’ function (which I have turned on) was to enable Account/Contact/Opportunity triggers on conversion.

 

How do I code a trigger for on convert? Sfdc help doesn’t have it listed as a possible event for a trigger and I’ve tried :

 

trigger test on Lead (before convert){ }

 

I get an invalid token error.

 

Thanks

 

Dan

 

 

 

jkucerajkucera

trigger afterConvert on Lead (after Update){
For (Integer i=0;i<Trigger.new.size();i++){
if(Trigger.new[i].IsConverted!=Trigger.old[i].IsConverted){
//do stuff
}
}
}

 Other approaches of coding it:

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=10740

 

You really don't need Trigger.Old given a lead can't be updated once converted, but my above trigger will still work if this ever changes.