web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Business required field

(1) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all,

I have two fields on opportunity form Method and Require. Require field is two options type as shown below

1682.Untitled1.png

When Require field is set to Yes. The Method field behave like business required field on form. Is there any way to do so.?

I tried to make workflow but not find How to make a work flow which fulfill my requirement.

Thank you

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Wayne Walton Profile Picture
    13,730 on at

    you need JavaScript.  It will look something like this:

    Xrm.Page.getAttribute("CRMFieldSchemaName").setRequiredLevel("required");

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Wayne Walton

    I will go through this approach and let you know further queries.

    Thank you

  • Suggested answer
    meenoo Profile Picture
    7,316 on at

    Hi Abdul,

    You can create a business rule as well to implement this:

    if 'Require' field is set to Yes

    Action: Make 'Method' field Business Required

    Thank you.

  • Wayne Walton Profile Picture
    13,730 on at

    He's on 2011, no business rules.

  • meenoo Profile Picture
    7,316 on at

    Sorry, haven't noticed the screenshot.

    Thanks Wayne.

  • Verified answer
    PS Profile Picture
    23,577 on at

    Hi Abdul,

    Try the following script, just change the field names:

    function requiredmethod_onchange() {

     var require = Xrm.Page.getAttribute('aw_require').getValue();

     if (aw_require == 1) {

       Xrm.Page.getAttribute("aw_method").setRequiredLevel("required");

     }

    }

    URL for help: alexanderdevelopment.net/.../dynamically-setting-field-requiredlevel-attributes-in-dynamics-crm-2011

  • Community Member Profile Picture
    on at

    I think Prashant's way is working.

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Prashant Shukla, Wayne Walton and Biao Xiao

    I wrote Prashant Shukla's code on Onchange event. Opportunity form allowed me to save opportunity first time but second time It is giving me error for the required field. I wrote code onSave event but the behavior is same. Why it is not working for the first time ?

    Thank you

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Prashant Shukla, Wayne Walton and Biao Xiao

    I also wrote this but it still saving for the first time

    function requiredmethod_onchange() {
    Xrm.Page.data.entity.addOnSave;
    var require = Xrm.Page.getAttribute('aw_require').getValue();
    if (aw_require == 1) {
    Xrm.Page.getAttribute("aw_method").setRequiredLevel("required");
    }
    }

    Thank you

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Prashant Shukla, Wayne Walton and Biao Xiao

    After saving first time it make this field required. I also add Xrm.Page.data.entity.addOnChange but it still behaving same

    Thank you

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans