Dynamic value set via Ajax in Accounts/Any modules in create page, But If click save button automatically got erased.

$("input[name=name]").val('test'); 

when applying the value using Jquery. then after clicking the save button value is automatically erased and throws the required error message.

Parents
  • Depending on your scenario, you could use the formula in Studio to set the name of the record.
    For example, I set Opportunity Nmae as a concatenation of Account Name, Close Date and another custom field. The downside is that it makes the field read only so the user cannot override that value, which, depending on scenarios may not be what you want.

    When I need to set a field in a controller, I use the Sidecar MVC framework and set the value for the field in the model in the module's custom extension of create.js, for example:

    this.model.set('<field_name>', "<value>");

    This will set the value for the field. Then when the user saves the record that field will also be saved.

    I think the problem you are having is that you are basically setting what the person sees but not the value in the bean,  the field in the model is not actually changed so the changedAttributes will not include the field you updated and it won't be saved.

    FrancescaS

Reply
  • Depending on your scenario, you could use the formula in Studio to set the name of the record.
    For example, I set Opportunity Nmae as a concatenation of Account Name, Close Date and another custom field. The downside is that it makes the field read only so the user cannot override that value, which, depending on scenarios may not be what you want.

    When I need to set a field in a controller, I use the Sidecar MVC framework and set the value for the field in the model in the module's custom extension of create.js, for example:

    this.model.set('<field_name>', "<value>");

    This will set the value for the field. Then when the user saves the record that field will also be saved.

    I think the problem you are having is that you are basically setting what the person sees but not the value in the bean,  the field in the model is not actually changed so the changedAttributes will not include the field you updated and it won't be saved.

    FrancescaS

Children
No Data