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 :
Finance | Project Operations, Human Resources, ...
Answered

make mandadory false to standard form control

(4) ShareShare
ReportReport
Posted on by 54
Hi, I have a standard parameters form, and one parameter control is mandatory at the control property level. Refer to the below. I need to customize the parameters and run the process without the 'editRuleid' control value.
There is a mandatory check that throws an error. I tried to change mandatory to 'false' in the code level, but the form controls do not support this at the code level, and this is not a table field.
Let me know if you have an idea to fix this.
I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
     
    You need to create form class extension :
    [ExtensionOf(formStr(LedgerAllocationRequest))]
    final class LedgerAllocationRequest_Frm_Extension
    {
        public void init()
        {
            next init();
            this.design().controlName(formControlStr(LedgerAllocationRequest, editRuleID)).mandatory(false);
        }
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • SC-25021032-0 Profile Picture
    54 on at
    @Mohamed Amine Mahmoudi , Thank you for your suggestion . I have tried that already but i got this error,
     
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    You are trying to dig a hole (or tunnel) that seems to have no end. The standard Dynamics classes and logic will not allow you to proceed without an allocation rule ID.

    The LedgerAllocationProcessRequest class will return a warning— "No record found for the source" — if no rule ID is provided.

    I suggest going back to the person who requested this work and asking for the business reason behind it. What exactly are they trying to achieve with such a customization? Remember, coding is not the answer to every problem.



     
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
     
    I've obviously forgotten something.
    try this :
    [ExtensionOf(formStr(LedgerAllocationRequest))]
    final class LedgerAllocationRequest_Frm_Extension
    {
        public void init()
        {
            next init();
            FormStringControl   formRuleId = this.design().controlName(formControlStr(LedgerAllocationRequest, editRuleID)) as FormStringControl;
            formRuleId.mandatory(false);
        }
    
    }
     
  • Suggested answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at
    Let's not overcomplicate it:
    public void init()
    {
        next init();
            
        editRuleID.mandatory(false);
    }
  • Suggested answer
    SC-25021032-0 Profile Picture
    54 on at
    @Sohaib Cheema, We are creating group and assign to rule master . Then based on group parameter it should process all the rules which are assigned to that group . So its concept of multiple rule processing .
     
    I am just trying to bypass mandatory error for that rule id field .
  • SC-25021032-0 Profile Picture
    54 on at
    @Mohamed Amine Mahmoudi @Martin DrábI have tried both options but nothing helping :(
     
     
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
     
    this message appears when you call the closeOk() method. i.e. there's a check to see if the field is filled in or not.
     
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
     
    I suggest you override the “validateAllocationRule” method too.
    [ExtensionOf(formStr(LedgerAllocationRequest))]
    final class LedgerAllocationRequest_Frm_Extension
    {
        public void init()
        {
            next init();
            FormStringControl   formRuleId = this.design().controlName(formControlStr(LedgerAllocationRequest, editRuleID)) as FormStringControl;
            formRuleId.mandatory(false);
        }
    
        protected boolean validateAllocationRule()
        {
            boolean ret = next validateAllocationRule();
    
            ret = true;
    
            return ret;
        }
    
    }
     
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at
    You can address your requirements by rethinking and redesigning the solution. If I understand correctly, you want to run the allocation process multiple times — once for each rule in a group of rules.
    Here are some important points to consider:
    1. The standard process uses runOperation(), which displays a progress dialog during execution.
      When running the process for multiple rules, you likely want to avoid this popup, especially if the runs are unattended or automated.
    2. Making the ruleId non-mandatory will require significant changes.
      The standard process checks in many places for the valid ruleId. Without Rule Id, this business process cannot execute.
    Therefore, somewhat better (if not the best) approach is to call the process separately for each ruleId in your group, like this:
    LedgerAllocationRequest req = LedgerAllocationRequest::construct();
    
    // Initialize parameters (as if the user filled the dialog)
    req.initParameters(
    'HR',                          // ruleId //use your own, it is from USMF Data
    today(),                            // asOfDate
    today(),                            // glPostDate
    LedgerAllocationZeroSourceMode::Process, // zeroSource
    LedgerAllocationProcessMode::ProposalOnly,    // processOptions
    22565420926,                         // reasonRefRecId//get it from ReasonTable
    today()                             // releaseDate
    );
    
    // Optionally set FinTagRecId
    //req.parmFinTagRecId(5637150000); // I am not using Financial Tags, you can if you need to, get the correct value
    
    // Run the operation directly, bypassing the UI
    req.run();//req.runOperation(); will show Progress dialog // Calls run() -> allocate()
    
    info("Ledger Allocation executed.");
    
    You can further improve the solution by:
    • Adding logging with a unique trace ID for each run, storing logs in a custom table if the process is run non-interactively.
    • Deciding on error handling: if one rule fails, should the remaining rules continue to run or should the entire batch stop?
    Whilst it’s possible to enhance the process using the SysOperation framework and few other ways, the standard allocation process is based on a bit older code patterns. To ensure compatibility with future Microsoft updates, I recommend minimizing changes along the existing baseline code.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans