Thursday, June 10, 2010

ForceSubmit Property

There are a lot of scenarios where you need to automatically populate a field when it is read-only or will be set read-only dynamically.  In this scenario you would want the value to be saved when the user clicks Save, but by default a field that is read-only will not submit.  To get a read-only field to submit, you can set the ForceSubmit property of the field to true using javascript:

crmForm.all.name.ForceSubmit = true;

What ForceSubmit actually does is always submit that attribute to be saved, whether or not it was actually modified on the form.  One thing to note is that if you have a plugin that is filtering on an attribute where ForceSubmit is set to true, then your plugin will always be triggered when the user saves the form.  Also if you set ForceSubmit to true on ownerid then it will always execute an Assign message whether or not the owner was actually changed.

Because of the way ForceSubmit works, the best way to use it would be to only set it if the field was actually changed (unless you want the field to always submit).



2 comments:

  1. Hi Blake,

    I am automatically setting the date/time to the current date/time when a user clicks Report Completed. I dont want the users to get any ideas that they can change the time they completed a report. So date/time is auto geneterated and set to read only. Where do I put the .forcesumbit?

    I am assuming on the Onchange event for the field that sets the date/time in the first place.

    ReplyDelete
  2. Paul,

    Correct, I would put it right after the code that sets the read only field.

    Thanks,
    Blake

    ReplyDelete