We have a client which uses Marketo forms / landing pages. On the form we take the firstname and lastname as mandatory fields however the line of business does not require a "Company Name" field. This being said Salesforce will not sync without it.
After discussing with them they would like the company name to be "Firstname Lastname".
How can we achieve this on form builder? If not possible what is the right way to achieve this?
Thanks.
<script>
MktoForms2.whenReady(function(form){
form.onSubmit(function(form){
var currentVals = form.getValues();
form.addHiddenFields({
Company: [currentVals.FirstName, currentVals.LastName].join(" ")
});
});
});
</script>
Thank you. Do I need to add this on the landing page as an additional script?
Yes, place it just before the closing </body> tag.
HI Hossein,
You can also create a smart campaign with a "change dat avalue' flow step:
choice: if company is empty
field to change : company. New value {{leaf.first name}} {{lead.last name}}
-Greg
This approach is what I prefer.
I agree, I would prefer to do it with a Smart Campaign since it would be easier if the company name format ever needed to change. Sanford's solution is a good one, but would require manual updates to each form page.
But this method won't always work depending on what else you have running. You have to make sure this runs before any process that explicitly or implicitly syncs the lead to CRM, which in the implicit case can be impossible and, even in the explicit case, makes for more complexity. I 100% think this should be done on the form side because we don't have the hooks on the server side to do the equivalent.
That's a fair statement. As a person that manages about 40 different forms distributed through many pages on our 4 websites, this would be a nightmare for me to track down every form and make sure they were updated.
It seems much easier to simply make this the first step in a Fills out Form smart campaign and on the off chance the sync happens before the campaign runs it should be updated for the next sync, no?
It seems much easier to simply make this the first step in a Fills out Form smart campaign and on the off chance the sync happens before the campaign runs it should be updated for the next sync, no?
Not really an off-chance in the case of CRM-synced Programs with local forms.
I suppose if you're willing to wait for it to fail once or twice before completing -- but that's an explanation I'd prefer to avoid!
As far as rolling out the change, presumably you have some sort of common footer to which you could add the JS... IMO if you would have ended up pasting it separately into tons of pages, that itself is a warning sign.