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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Call modified method of form control from another modified method of a form control

(1) ShareShare
ReportReport
Posted on by 313
Hello everyone,
 
We have a form that was created to enter items more easily.  On that form we have Item Group, Major Group, Minor Group and Item Template.
 
Right now, under the form control of Item Template, I have overwrote the modified method so that it finds the settings of the chosen Item Template and fills in the form accordingly.  This works perfectly.
 
After a user it tabbing through and fills out Item Template, and Major Group, then it looks up what Item Template is chosen for that combination and fills it in.  It does this in the modified method of Major Group.
 
I want it to execute the modified method of Item Template as soon as that happens so the rest of the form is filled out correctly.  I had this working by using element.redraw() and then calling the modified method, but if I change the major group after that, the item template doesn't update.
 
For example
Let's say I have Item Group IG001
And two Major Groups  MG001 and MG002

IG001 and MG001 use Item Template IT001
IG001 and MG002 use Item Template IT002
 
Also IT001 has Phantom set to yes
IT002 has Phantom set to no
Phantom is a setting for items and is on the form
 
So if a user tabs through, fills in IG001 and MG001, then using the modified method of major group, I am able to fill out item template with IT001.  I will post the code below.
 
Now if I use the code element.redraw() and call the modified method of item template, then it works and fills out Phantom correctly, but if I go back and change MG001 to MG002, the item template doesn't change even though it hits the code.
If I get rid of element.redraw() and the line calling the modified method, then the item template will update as soon as I choose the Major Group.
 
I need both things to work.  Hopefully this all makes sense.  I tried to give us much detail as possible....
I have the same question (0)
  • Andrew Huisman Profile Picture
    313 on at
    Call modified method of form control from another modified method of a form control
    Here is the code
     
    public boolean modified()
            {
                boolean ret;
                AMInventItemMajorGroup  amInventItemMajorGroup;
        
                ret = super();
    
                TCI_ItemTable.TemplateNumber = '';
                //element.redraw();
    
                //TCI_ItemTable.MinorGroup = '';
                
                //TCI_ItemTable.CoverageGroup = '';
                //TCI_ItemTable.InventorySite = '';
                //TCI_ItemTable.Phantom = NoYes::No;
    
                //Create a new query
                Query                   query = new Query();
                QueryBuildDataSource    queryBuildDataSource;
                QueryBuildRange         queryBuildRange, queryBuildRange2;
                QueryRun                qr;
    
                //Specify the name of the table the lookup should show data from.
                queryBuildDataSource = query.addDataSource(tableNum(AMInventItemMajorGroup));
                queryBuildRange = queryBuildDataSource.addRange(fieldNum(AMInventItemMajorGroup,MajorGroupId));
                queryBuildRange.value(queryValue(TCI_ItemTable.MajorGroup));
                queryBuildRange2 = queryBuildDataSource.addRange(fieldNum(AMInventItemMajorGroup,ItemGroupId));
                queryBuildRange2.value(queryValue(TCI_ItemTable.ItemGroup));
                
                qr = new QueryRun(query);
       
                while (qr.next())
                {
                    amInventItemMajorGroup = qr.get(tablenum(AMInventItemMajorGroup));
                    TCI_ItemTable.TemplateNumber = amInventItemMajorGroup.ItemTemplateId;
                }
    
                //TCI_ItemTable_TemplateNumber.modified();
    
                return ret;
            }
     
  • Verified answer
    Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    Call modified method of form control from another modified method of a form control
    Hi Andrew,
     
    Is the control that you call it's modified method bound to a datasource?
     
    If yes maybe try sth like this instead of calling the control directly or using redraw. Replace the below example with your correct datasource and correct fields:
    taxWithholdTrans_ds.object(fieldnum(taxWithholdTrans, TaxWithholdCode)).modified();  
     
    Sorry I didn't read the whole details u wrote but hopefully it will help..let us know
     
    Thanks,
    Layan Jweihan
  • Andrew Huisman Profile Picture
    313 on at
    Call modified method of form control from another modified method of a form control
    The methods are all bound to the control and not the datasource.  I don't want to affect it in other places, just this control.
  • Andrew Huisman Profile Picture
    313 on at
    Call modified method of form control from another modified method of a form control
    I just tried what you said, but it didn't work.  But I'm assuming you need me to move my modified method code off the control and onto the datasouce field.  I can try that but I'm still curious how to get it to work the way I have it.
  • Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    Call modified method of form control from another modified method of a form control
    Hi Andrew,
     
    By "bound to datasource" i meant, does this "item template" control has it's "data source" property filled?
     
    So I'm assuming you have a table that has the following fields:
    ItemGroupId, itemTemplateId, MajorGroupId, MinorGroupId
     
    and I would say:
    - ItemGroupId has a relation with InventItemGroup table
    - ItemTemplateId has a relation with with a certain table related to templates
    - MajorGroupId has a relation with with InventItemGroup & a certain table related to major groups
    - MinorGroupId has a relation with with InventItemGroup & a certain table related to minor groups
    right?
     
    and now you added this table to a form, where those 4 fields were included?


    Thanks,
    Layan Jweihan
  • Suggested answer
    Andrew Huisman Profile Picture
    313 on at
    Call modified method of form control from another modified method of a form control
    Yes that is all correct.
     
    I've continued working and moved the modified code to the modified method on the datasource field instead and it works great
  • Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    Call modified method of form control from another modified method of a form control
    Hi Andrew,

    Can you share the new code?
    And did the line of code i shared regarding datasource helped you? if yes then please mark answers that helped you as verified (if there were any)

    Thanks,
    Layan Jweihan
     
  • Suggested answer
    Andrew Huisman Profile Picture
    313 on at
    Call modified method of form control from another modified method of a form control
    Hi Layan,
     
    Yes, your code did help after I put the method on the datasource field. Thank you and I will mark your post as one of the answers.
     
    Here is my code on the datasource field
    /// <summary>
                ///
                /// </summary>
                public void modified()
                {
                    AMInventItemTemplate    amInventItemTemplate;
                    
                    super();
    
                    //Create a new query
                    Query                   query = new Query();
                    QueryBuildDataSource    queryBuildDataSource;
                    QueryBuildRange         queryBuildRange;
                    QueryRun                qr;
    
                    //Specify the name of the table the lookup should show data from.
                    queryBuildDataSource = query.addDataSource(tableNum(AMInventItemTemplate));
                    queryBuildRange = queryBuildDataSource.addRange(fieldNum(AMInventItemTemplate,TemplateId));
                    queryBuildRange.value(queryValue(TCI_ItemTable.TemplateNumber));
                
                    qr = new QueryRun(query);
       
                    while (qr.next())
                    {
                        amInventItemTemplate = qr.get(tablenum(AMInventItemTemplate));
                        TCI_ItemTable.CoverageGroup = amInventItemTemplate.ReqGroupId;
                        TCI_ItemTable.InventorySite = amInventItemTemplate.InventSiteId;
                        TCI_ItemTable.Phantom = amInventItemTemplate.Phantom;
                    }
                }
    And here is my code on the form grid control that calls this method
    public boolean modified()
            {
                boolean ret;
                AMInventItemMajorGroup  amInventItemMajorGroup;
        
                ret = super();
    
                TCI_ItemTable.TemplateNumber = '';
                TCI_ItemTable.MinorGroup = '';            
                TCI_ItemTable.CoverageGroup = '';
                TCI_ItemTable.InventorySite = '';
                TCI_ItemTable.Phantom = NoYes::No;
    
                //Create a new query
                Query                   query = new Query();
                QueryBuildDataSource    queryBuildDataSource;
                QueryBuildRange         queryBuildRange, queryBuildRange2;
                QueryRun                qr;
    
                //Specify the name of the table the lookup should show data from.
                queryBuildDataSource = query.addDataSource(tableNum(AMInventItemMajorGroup));
                queryBuildRange = queryBuildDataSource.addRange(fieldNum(AMInventItemMajorGroup,MajorGroupId));
                queryBuildRange.value(queryValue(TCI_ItemTable.MajorGroup));
                queryBuildRange2 = queryBuildDataSource.addRange(fieldNum(AMInventItemMajorGroup,ItemGroupId));
                queryBuildRange2.value(queryValue(TCI_ItemTable.ItemGroup));
                
                qr = new QueryRun(query);
       
                while (qr.next())
                {
                    amInventItemMajorGroup = qr.get(tablenum(AMInventItemMajorGroup));
                    TCI_ItemTable.TemplateNumber = amInventItemMajorGroup.ItemTemplateId;
                }
    
                TCI_ItemTable_ds.object(fieldNum(TCI_ItemTable, TemplateNumber)).modified();
    
                return ret;
            }
    
        }
     

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans