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

To get the value of radio button on custom form from another form

(1) ShareShare
ReportReport
Posted on by 1,836
In users there is assign organisation tab where there is radio button on that radion button when the selection is all i show all organisation, there i need to filter my lookup when selection is specific organisation i want to show organisation only the selectied organisation can can you please guide me on this my code is below 
[Form]
public class EmployeePayrollDetails extends FormRun
{
     
    OrganizationAccess grantType;
    /// <summary>
    ///
    /// </summary>
    public void init()
    {
        super();
        Args args = new Args();
        args.name(formStr(SysSecRoleAssignOM));
        args.caller(element);

        FormRun formRun = new FormRun(args);
        // Now retrieve the value passed back
     
        FormRadioControl    selection = formRun.control(formRun.controlId(formControlStr(SysSecRoleAssignOM,grantAccessRadioButton))) as FormRadioControl;
        FormDataSource         formDs = formRun.dataSource(formDataSourceStr(SysSecRoleAssignOM,omUserRoleOrganization));
        OMUserRoleOrganization  omOrg = formDs.cursor();
            
        if (selection)
        {
            grantType = selection.selection();
        }
    }

        [Control("String")]
    class CompanyName
    {
        /// <summary>
        ///
        /// </summary>
        public void lookup()
        {
            super();
           
            Query query = new Query();
            QueryBuildDataSource qbdsCompany = query.addDataSource(tablenum(CompanyInfo));
          
            if (grantType == OrganizationAccess::Organization)
            {
                // Add join to filter companies based on user-role organization access
                QueryBuildDataSource qbdsOrg = qbdsCompany.addDataSource(tablenum(OMUserRoleOrganization));
                qbdsOrg.relations(false);
                qbdsOrg.joinMode(JoinMode::InnerJoin);
                qbdsOrg.addLink(
                       fieldnum(OMUserRoleOrganization, omInternalOrganization),
                       fieldnum(CompanyInfo, RecId));

                // Filter only the current user’s organization access
                qbdsOrg.addRange(fieldnum(OMUserRoleOrganization, User)).value(queryValue(curUserId()));
            }

            // Create the lookup
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(CompanyInfo), this);
            sysTableLookup.parmQuery(query);

            // Show DataArea (legal entity) and Name
            sysTableLookup.addLookupField(fieldnum(CompanyInfo, DataArea));
            sysTableLookup.addLookupField(fieldnum(CompanyInfo, Name));

            sysTableLookup.performFormLookup();
        }

    }

  

}
 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at
    Your code doesn't make sense to me, so let's ignore it for now. What is the business requirement you're trying to address?
     
    By the way, please pay more attention to categories you select for your threads. For instance, this one clearly isn't about Dynamics GP.
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi Martin thanks for reply
    , I have created the dialogue form having field which contains company name.
    In users, when we open the specific user , there is button on second tab which opens assign organisation form in that fom there is button on the form design that when user is selected all the all company he have access and when the button is selected as specific the selected company the user have access so i am trying to get my lookup filtered according to the button selection , so i call the form in my custom dialog box form but the button selection value is null so my filter dont work here. this is requirement as of now .
  • Dineshkarlekar Profile Picture
    1,836 on at
    let me know if i am doing anything wrong , should i use event handler for this . 
  • Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at
    You said you created a dialog and described some standard logic, but it's not clear how these things are related. Where and when do you use your dialog?
     
    Which form do you mean when saying "I call the form in my custom dialog box form"?
     
    Where is the lookup?
     
    Please be much more specific. Describe what the users do to get to your dialog, where the lookup is placed and how it's all related to the users form etc. described before. Screenshots will help, if you're struggling with desciring it in text.
     
    If you believe that your code in EmployeePayrollDetails form calls SysSecRoleAssignOM form, you're wrong. You're refering to SysSecRoleAssignOM, but the code doesn't open the form and it doesn't really make sense to me.
  • Dineshkarlekar Profile Picture
    1,836 on at
    I created  form design and from name is EmployeePayrollDetails , the design pattern is dialog basic and the datasource is OMUserRoleOrganization   i have written the code on lookup  which is multislect lookup , what i have to do  is in user roles assign organisation is button will open another form that is form SysSecRoleAssignOM  with button ,grantAccessRadioButton 
    so when i select in my lookup i want to put the condition that if grant access to all is selected then lookup will show all the organisation and if grant specific is selected then lookup will show  only the organisation which the user have access. below is my lookup dialog form. let me know if you want anything else , my multiselect lookup code is working but i have not pur any condition yet.
     
     
      
     
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    below is my code for multiselect lookup 
    [Form]
    public class EmployeePayrollDetails extends FormRun
    {
    
        [Control("String")]
        class CompanyName
        {
            /// <summary>
            ///
            /// </summary>
            public void lookup()
            {
                super();
                
                UserInfo    userInfo;
                SysLookupMultiSelectCtrl  msLookupCtrl;
                Args args = new Args();
                args.name(formStr(SysSecRoleAssignOM));
                args.caller(element);
               
                FormRun formRun = new FormRun(args);
                // Now retrieve the value passed back
         
                FormRadioControl    selection = formRun.control(formRun.controlId(formControlStr(SysSecRoleAssignOM, radiogroup))) as FormRadioControl;
                FormDataSource         formDs = formRun.dataSource(formDataSourceStr(SysSecRoleAssignOM,omUserRoleOrganization));
                //OMUserRoleOrganization  omOrg = args.record();
    
                //select * from userInfo
                //    join omOrg
                //    where omOrg.User == curUserId();
                OrganizationAccess grantType;
                Query query = new Query();
                QueryBuildDataSource qbdsCompany = query.addDataSource(tablenum(CompanyInfo));
              
                //if (grantType == OrganizationAccess::Organization)
                //{
                    // Add join to filter companies based on user-role organization access
                    QueryBuildDataSource qbdsOrg = qbdsCompany.addDataSource(tablenum(OMUserRoleOrganization));
                    qbdsOrg.relations(false);
                    qbdsOrg.joinMode(JoinMode::InnerJoin);
                    qbdsOrg.addLink(
                           fieldnum(OMUserRoleOrganization, omInternalOrganization),
                           fieldnum(CompanyInfo, RecId));
    
                    // Filter only the current user’s organization access
                    qbdsOrg.addRange(fieldnum(OMUserRoleOrganization, User)).value(queryValue(curUserId()));
                //}
                qbdsCompany.addSelectionField(fieldNum(CompanyInfo, DataArea));
                qbdsCompany.addSelectionField(fieldNum(CompanyInfo, Name));
    
                msLookupCtrl = SysLookupMultiSelectCtrl::constructWithQuery(this.formRun(), this, query);
                msLookupCtrl.set(msLookupCtrl.getSelectedFieldValues());
            }
    
        }
    }
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    I commented the code because not getting the value of the button.please let me know if you want to anything about it .
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi @Martin Dráb let me know if you have any doubt and am i doing it in wrong way.
  • Verified answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at
    The radio button isn't something your can refer to if your dialog has no reference to a particular instance of SysSecRoleAssignOM form. Your description didn't mentioned that your code about SysSecRoleAssignOM doesn't do anything useful, therefore I'm assuming it was just a wrong design that we can ignore.
     
    But what you can refer to is the data in database. My understanding of the logic about the radio button is that there is a record in OMUserRoleOrganization table (for the given User and SecurityRole) if it's related to a particular organization, and there is no record if the organization access is All. Look into setInitialValue() method of SysSecRoleAssignOM form to see an example. You said that the data source of your form is OMUserRoleOrganization, therefore it seems to be always related to an organization and never to All.
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi Martin ,
    My issue is resolve now i have change my lookup code.
    I am going to work further on this form will create another thread for this. 
    thanks,
    Regards,
    Dinesh
     OMUserRoleOrganization omOrg;
        boolean hasOrgAccess = false;
    
        // Check if the current user has any organization access records
        select firstonly RecId from omOrg
            where omOrg.User == curUserId();
    
        hasOrgAccess = (omOrg.RecId != 0);
    
        Query query = new Query();
        QueryBuildDataSource qbdsCompany = query.addDataSource(tablenum(CompanyInfo));
        
        qbdsCompany.addSelectionField(fieldNum(CompanyInfo, DataArea));
        qbdsCompany.addSelectionField(fieldNum(CompanyInfo, Name));
    
        if (hasOrgAccess)
        {
            QueryBuildDataSource qbdsOrg = qbdsCompany.addDataSource(tablenum(OMUserRoleOrganization));
            qbdsOrg.relations(false);
            qbdsOrg.joinMode(JoinMode::InnerJoin);
            qbdsOrg.addLink(
                fieldnum(OMUserRoleOrganization, omInternalOrganization),
                fieldnum(CompanyInfo, RecId));
            
            qbdsOrg.addRange(fieldnum(OMUserRoleOrganization, User)).value(queryValue(curUserId()));
        }
    
        msLookupCtrl = SysLookupMultiSelectCtrl::constructWithQuery(this.formRun(), this, query);
        msLookupCtrl.set(msLookupCtrl.getSelectedFieldValues());
     

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
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans