SOLVED

Re: Small issue with when using SimpleDTO.js

Go to solution
Sanchidrian
Level 2

Small issue with when using SimpleDTO.js

Hello, 
One of our supplier helping us to deploy Marketo used progressive profiling script from @SanfordWhiteman on our Website to get benefit from Progressive Profiling when Landing Page isn't hosted on Marketo.

Progressive profiling is working fine when the contact is recognized. However, for unknown people reaching our form, we noticed a small issue related to predefined fields. Actually, we do have a field to select the country that is set to a predefined value. When person isn't known and recognized, the default value is removed. We did try to debug script to understand what is happening. In debug mode, we saw that at the begining of the display of the page, our default value for country is well displayed. However, later call of simpleDTO script is removing the value. We noticed that this happens at following steps in the script:

MktoForms2.whenReady(function(form) {
          form.setValuesCoerced(mktoFields);
        }); 

 

Not sure if it is normal, so this is why we raised it. In the meantime, we solved it at our website level by forcing it through another script.

 

 

Note : was applied what is listed in Sanford blog -->  https://blog.teknkl.com/pre-fill-any-site-any-form/

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Small issue with when using SimpleDTO.js

That's expected behavior. If the field is empty and you prefill an empty value, that's still a valid value.

 

You can remove the empty values from the fields object if you want, although I'd caution that there are situations where Pre-Filling the empty value is appropriate.

MktoForms2.whenReady(function(form) {
  Object.keys(mktoFields).forEach(function(key){
    if (mktoFields[key] === "") delete mktoFields[key];
  })
  form.setValuesCoerced(mktoFields);
});

 

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Small issue with when using SimpleDTO.js

That's expected behavior. If the field is empty and you prefill an empty value, that's still a valid value.

 

You can remove the empty values from the fields object if you want, although I'd caution that there are situations where Pre-Filling the empty value is appropriate.

MktoForms2.whenReady(function(form) {
  Object.keys(mktoFields).forEach(function(key){
    if (mktoFields[key] === "") delete mktoFields[key];
  })
  form.setValuesCoerced(mktoFields);
});

 

Sanchidrian
Level 2

Re: Small issue with when using SimpleDTO.js

Thanks @SanfordWhiteman 
Your update works like a charm ! It is perfect. 😀