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

  • Dear Chris,

    Thanks alot!!

    It was my mistake I have updated the formula and now its working for me, but when I try to create custom module record from Accounts subpanel that field is required can you please suggest how to handle that?

    Kindest Regards,

    Shreya

  • Hi ,

    I'm not sure I understand the scenario. Are you wanting the same Client relate field to not be required if you are creating an account from the subpanel of another custom module? If so, what type of relationship does that custom module have with accounts (many-to-many or one-to-many)?

    Chris

  • Use case:

    Relationship is : 1 account to M <cust_module>

    When I trying to create record say "for cust_module" module form subpanel of account then I want to make custom relationship field present on cust_module quick create view as non mandatory.

    Hope this helps.

    Kindest Regards,

    Shreya

  • Hi ,

    I fear I'm still not fully understanding the scenario. This is what it seems to be:

    1. You have the custom module (Module X)
      1. Module X is part of your lead conversion flow
      2. Module X has a many-to-1 relationship to the Client (Accounts) module
      3. With the solution I provided, the Client relationship field is not required for the Module X record during lead conversion but is required when creating a Module X record elsewhere
      4. You want that same field on Module X to not be required when creating a Module X record from the Module X subpanel of a Client record

    Is that correct? If so, I am having trouble understanding the validity of this use case. When creating a Module X record from the Module X subpanel of a Client record, the relationship field should be automatically populated with the current Client record in order to establish the relationship. If you were to delete the pre-filled value in that field, it would be required due to the solution implemented, but again, I don't understand why that would be a desirable workflow.

    If I am misunderstanding, please provide more specific information. Actual module names, system field names you are working with, and screenshots are helpful and can help pinpoint where the misunderstanding is.

    Chris

  • Dear Chris,

    You are right, When creating a Module X record from the Module X subpanel of a Client record, the relationship field should be automatically populated with the current Client record in order to establish the relationship.

    But I have another module custom relationship with Module X and I want to make that as non mandatory when user creating Module X record from the Module X subpanel of a Client record.

    Hope you have understood now.

    Kindest Regards,

    Shreya

Reply
  • Dear Chris,

    You are right, When creating a Module X record from the Module X subpanel of a Client record, the relationship field should be automatically populated with the current Client record in order to establish the relationship.

    But I have another module custom relationship with Module X and I want to make that as non mandatory when user creating Module X record from the Module X subpanel of a Client record.

    Hope you have understood now.

    Kindest Regards,

    Shreya

Children