How to make custom relationship field required only for when user click on create view not record view using js file

Hi All,

We have made custom relationship field on accounts module non required as we don't want field to be required while converting lead on lead conversion page but we want field when create account using create button.
Can anyone suggest, how to make custom relationship field required only for when user click on create view not record view?
How to make field required using js?

Kindest Regards,
Shreya

Parents
  • Hi ,

    This solution should be achievable without the need for coding! When converting leads, any fields that exist between the lead record and the target record being created during conversion will have their values carried over from the lead. By leveraging that concept, you can use Sugar Logic to validate whether the account creation is coming from a lead conversion or some other means. Here are the steps I took to make a relationship field (or any other field) conditionally required on account creation but not lead conversion:

    1. Create a dropdown field in the Accounts module with a dropdown list of a blank value, 'Yes', and 'No'. Ensure the default value is set to the blank or 'No' option. In my example, I called the field 'lead_conversion':



      The field does not need to be added to the account record view layout. 
    2. Go to the relationship field in Studio and check the 'Required' box. Then fill in the following formula for the 'Required If' condition:
      not(equal($lead_conversion_c,"Yes"))




    3. Create a dropdown in the Leads module referencing the same dropdown list. Set the default value to 'Yes'. The field must be the same name as the dropdown field you created in step 1!



      As with the accounts module, this field does not need to be added to the record view layout. It will function behind the scenes.
    4. Mass update any existing leads to set the dropdown value to 'Yes' for your new field.
    5. Now, when converting a lead, the relationship field will not be required since the dropdown value is carried over to the account and the Sugar Logic formula does not validate:



      And when creating new accounts, the field will be required since that dropdown field passes the Sugar Logic formula validation:

    I hope this helps!

    Chris

  • Dear Chris,

    Thanks for help!

    I followed the steps  above but field shows required in create and conversion layout looks like Sugar Logic formula validation not working, I have tried repaired and rebuild also but not working please suggest.

    I have cleared browser cache also but no luck.

    Kindest Regards,

    Shreya

  • Hi ,

    Please provide screenshots of how each field is configured in Studio as well as what you see on-screen when creating an account versus converting a lead. Also, for what version of Sugar are you implementing this solution?

    Chris

  • Dear Chris,

    As requested, please find details below:

    I want to make client/account relationship required only for creation, please check client field is required in both layouts.

    • Sugarcrm version is 13.0.0
    • Dropdown field in the custom module 

    • Dropdown field in the leads module:

    • Lead conversion layout:

    • custom module create page:

    • relationship field formula in custom module relationship field is :not(equal($lead_conversion_c,"Yes"))

    Kindest Regards,

    Shreya

  • Hi ,

    Are the dropdown keys the same as the display values? If so, can you try changing the formula to "YES" instead of "Yes"?

    Chris

Reply Children