SOLVED

Re: Script to updated a Custom field in marketo form

Go to solution
sg
Level 2
Level 2

Re: Script to updated a Custom field in marketo form

 

Sorry for this multiple posts, but still not able to update a field

Realized that Building field  is blocked for Form Fillouts.

sg_2-1680803844038.png

 

Now, Switching to COB_CustomData,  It is  still not working. I am clueless what is wrong here
API Name for COB_CustomData  is cOBCustomData  (lower c)

<script>
MktoForms2.whenReady(function(readyForm){
  const formEl = readyForm.getFormElem()[0],
        buttonEl = formEl.querySelector("#setCOBCustomData");
  
  if(buttonEl){
    buttonEl.addEventListener("click",function(e){
     alert('before set value');
      readyForm.setValues({
        cOBCustomData: "your value"
      });
       alert('after set value');
    });
  }
});
</script>

 

COB_CustomData is  NOT Blocked Updates From: None

 

sg_0-1680803543597.png

 

But the Change Data value is not triggered in the Activity log 

 

sg_1-1680803761639.png

 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Script to updated a Custom field in marketo form

You need to be more attentive to case-sensitivity.

 

Please:

 

1. Fix the fatal error from the other script (due to another typo in a field name).

2. Change all alert() to console.log()alert() is not the right troubleshooting tool for forms: it changes the form state (by moving focus) and is very distracting.

You can however see that the JSON data is posted with the form. Not sure what you’re trying to accomplish by posting all form values in this way, but they are being sent:

SanfordWhiteman_0-1680811770877.png