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

Need to find out if a Lead record in a Web-To-Lead is edit through the SF's interface


We are doing email validation solution.

The solution has two implementations:

1. An after update trigger which is installed on the Lead objects so that when a lead is updated from an external forma (in Facebook for example) the trigger fires a future method which does a webservice call which validates the email and replaces the current email with the validated one.

2. We have an interactive part where when a user edits the Lead record from the user interface we popup a window with both the original email and the validated email and let the user choose which one he/she wants to leave.


Now the problem is when we install both solutions and the user edits a lead from the user interface. Then the email will be validated by both our interactive solution and the trigger.

What we need is a way for the trigger to find out that that lead was updated by the user interface and not fire.

Ideally we would not want to extend the lead with another field and having the user interface fill in that field we are looking for minimum to non intrusive solution to this if possible.





If you don't want to use some other "flag" field for this, can you differentiate according to which User performed the edit?


It's hard to say whether this would work without knowing a little more; are you doing this "choose your email" interface from salesforce, or some other place?





Thank you for your response.

Cannot do it through the user.

And yes I am using some kind of a hack to redirect the user to another page for choosing a the email after update.

So basically the user edits the Lead through the interface and clicks save then the record is saved and my trigger fires I want that trigger to find out that the Lead was edited from the interface and do nothing.

Then when the page reloads I am redirecting the user to my interactive page for choosing the valid email. But that other page is Visual force page as well.

Even if I am to use a flag how would that work then? How do I make a hidden field in the Lead's interface which get updated on save or edit with some custom value so that I know that the edit was done from the interface?


I am currantly looking for any  solution actually.






Wanted to share one possible solution to this that I came up with although only theoretical I have not tried it yet.

Next to each email I have a field validation status.

The user isntalls our after update trigger validation and our interactive valiation on Leads.

Here is how the solution should work if the user edits a Lead from the SF interface:

1. The user updates a Lead record.

2. Our BEFORE update trigger fires and finds out if the email changed and changes the validation status to "Needs validation"

3. Record is saved to db.

4. Our after udpate trigger fires. It sees that both interactive validation and trigger validatin are turned on for the Lead and sleeps for 2 minutes (Need to figure out how to make it sleep). Of course the method in the trigger is @future since it calls a web serverce for validation the email and it sleeps.

5. Our interactive validation hack fires and changes only the status of the field to "Validation by interactive pending". It then redirects the user to do the validation page. This is our interactive validation solution.

6. The BEFORE update trigger fires sees that the email has not changed and exits.

7. The after update trigger fires again. It sees that the status is different than "Needs validation" and exists.

8. The after update trigger wakes up after the 2 minutes sleep and sees that the status is different than "Needs validation" and exits.


Seems too complicate to me but it seems like it will work.

Any simpler suggestions are welcome.