Pass "Firstname Lastname" as Company Name

Anonymous
Not applicable

Pass "Firstname Lastname" as Company Name

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.

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Pass "Firstname Lastname" as Company Name

<script>

MktoForms2.whenReady(function(form){

  form.onSubmit(function(form){

    var currentVals = form.getValues();

    form.addHiddenFields({

      Company: [currentVals.FirstName, currentVals.LastName].join(" ")

    });

  });

});

</script>

Anonymous
Not applicable

Re: Pass "Firstname Lastname" as Company Name

Thank you. Do I need to add this on the landing page as an additional script?

SanfordWhiteman
Level 10 - Community Moderator

Re: Pass "Firstname Lastname" as Company Name

Yes, place it just before the closing </body> tag.

Grégoire_Miche2
Level 10

Re: Pass "Firstname Lastname" as Company Name

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

Chris_Willis1
Level 8 - Champion

Re: Pass "Firstname Lastname" as Company Name

This approach is what I prefer. 

Steve_Carlton
Level 2

Re: Pass "Firstname Lastname" as Company Name

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: Pass "Firstname Lastname" as Company Name

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.

Steve_Carlton
Level 2

Re: Pass "Firstname Lastname" as Company Name

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?

SanfordWhiteman
Level 10 - Community Moderator

Re: Pass "Firstname Lastname" as Company Name

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.