Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Multi select lookup

Posted on by 210

Hi all, 

I want to create a master form from where we can select multiple account id from the lookup and store in the table.
Please guide me with the steps.

  • WillWU Profile Picture
    WillWU 22,350 on at
    RE: Multi select lookup

    Hi vikash,

    Please put the breakpoint on the appropriate code.

    It seems there is some problems on the code:TPZ_TopTenMasters.AccountId = TPZ_TopTenMasters_AccountId.valueStr();

    Please change it to TPZ_TopTenMasters.AccountId = this.text();

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multi select lookup

    I still don't see what value you have in the AccountId field in the debugger. Your screenshot only shows the return value of the modified method (true).

    And you still have the commented out code in TPZ_TopTenSales_AccountIdUpdate method.

  • vikash_ Profile Picture
    vikash_ 210 on at
    RE: Multi select lookup

    2818.Capture.PNG0361.Capture2.PNG

    [Form]
    public class TPZ_TopTenMaster extends FormRun
    {
        SysLookupMultiSelectCtrl      LookupMultiSelectCtrl;
      
       
    
        public void init()
        {
            super();
            // AccountNum- Name of control on which you want a lookup.
            // CustTableQry- Query to get the lookup data
            LookupMultiSelectCtrl= SysLookupMultiSelectCtrl::construct(element, TPZ_TopTenMasters_AccountId, querystr(TPZ_TopTenMasterQuery));
            
        }
    
        [DataSource]
        class TPZ_TopTenMasters
        {
            /// 
            ///
            /// 
            public void executeQuery()
            {
                super();  
                this.TPZ_TopTenSales_AccountIdUpdate();         
                
            }
    
            public void TPZ_TopTenSales_AccountIdUpdate()
            {
                container       mainAccounts;
    
                //Set the control value
                TPZ_TopTenMasters_AccountId.text(TPZ_TopTenMasters.AccountId);
    
                //Mark the appropriate checkbox in the drop down
                mainAccounts = conNull();
                mainAccounts = this.createContainer();
    
                if (mainAccounts != conNull())
                {
                    // Set controls for existing records
                    LookupMultiSelectCtrl.set(mainAccounts);
                }
                //else
                //{
                //    LookupMultiSelectCtrl.set(conNull());
                //}
            }
    
            /// 
            ///
            /// 
          
            public container createContainer()
            {
                List            list = new List(Types::String);
                ListIterator    i;
                container       RecIds, Names;
                RecId           id;
    
                list = Global::strSplit(TPZ_TopTenMasters.AccountId,";");
    
                i = new ListIterator(list);
                while(i.more())
                {
                    id = MainAccount::findByMainAccountId(i.value()).RecId;
                    RecIds  = id;
                    Names  = i.value();
                    i.next();
                }
    
                return [RecIds, Names];
                    
    
            }
    
        }
    
        [Control("String")]
        class TPZ_TopTenMasters_AccountId
        {
            /// 
            ///
            /// 
            /// 
            public boolean modified()
            {
                boolean ret;
                
            
                ret = super();
                ttsBegin;
                TPZ_TopTenMasters.AccountId = TPZ_TopTenMasters_AccountId.valueStr();
                info(TPZ_TopTenMasters.AccountId);
                
                //TPZ_TopTenMasters.update();
                ttsCommit;        
                return ret;
            }
    
        }
    
    }

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Multi select lookup

    Please be more specific. Where do things go wrong in createContainer()? Just telling us that you debugged the method but not what you found isn't very useful.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multi select lookup

    Your code still has a difference compared to the example in the blog - you have commented out some code in TPZ_TopTenSales_AccountIdUpdate method.

    Anyway could you please share us screenshots of following things:

    1) The lookup dialog itself when you test it, so that we can see that you have selected values

    2) The debugger in the end of modified method of the field, so that we can see if you have some value in the field

    And could you also share the latest version of your code? Thanks!

  • vikash_ Profile Picture
    vikash_ 210 on at
    RE: Multi select lookup

    Yes, I have debugged the createContainer method, no values are populating.

    I have changed the code and build it, no result.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multi select lookup

    Did you debug the createContainer method?

    One issue that I spotted is that in the modified method you run your logic before the super() call. You should run it after the super() call, just as demonstrated in the blog.

  • vikash_ Profile Picture
    vikash_ 210 on at
    RE: Multi select lookup

    Hi Martin,

    I'm not getting any value in info.

    I have also opened table browser but the field is blank.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multi select lookup

    I assume you already debugged it. 

    Please describe to us what you found out when debugging method "createContainer", and method "modified" of the account id field.

    
                          
  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Multi select lookup

    What problem do you have with your code?

    I see you commented out update() in modified(), but you have an infolog message there. Are you getting the right value in infolog?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans