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

How to pass the container in arguement?

(0) ShareShare
ReportReport
Posted on by 162
Hi,
I want to pass multiple records in arguement, therefore i have added them into container but I am getting the following error. Could not understand what's wrong. Please help.
 
//////// 
 
The code- 
 
str             userNameCon,UserLicenseCon,results;container       conUser,conLicense,record;Args        args = new Args();record = conIns(record,1,conUser);record = conIns(record,2,role);record = conIns(record,3,field.valueStr());results = con2Str(record,',');args.parm(results);
I am getting the error in args.parm();
I have the same question (0)
  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at
    This seems to be your code when I throw away unused variables.
    container record;
    
    record = conIns(record, 1, conNull());
    record = conIns(record, 2, role);
    record = conIns(record, 3, field.valueStr());
    str results = con2Str(record, ',');
    
    Args args = new Args();
    args.parm(results);
     
    It's not runnable, because it depends on an undefined variables called role and field.
     
    Which of the statements is throwing the exception? If it's about role, what is the data type of the variable?
     
    The screenshot is from F&O, therefore I'm going to move this thread from the AX forum to an F&O forum.
  • Harshal Jain Profile Picture
    162 on at
    Hi Martin, 
    I had edited the code so missed to declare the Role. 
    It is the buffer of  
     SecurityLicenseRole        role;
    Also the the conUser contains the following code - 
     
     conUser = conIns(conUser,1,Table.Id );
     And the field.valueStr () is the form field value which I am using
  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at
    Okay, now please tell us which of the calls throws the exception.
  • Harshal Jain Profile Picture
    162 on at
    Hi Martin
    I am getting an error at -
     
    args.parm(results);
  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at
    That's hard to believe, because there is no conversion involved.
     
    Can you give us code that we can run and see the problem for ourselves? Without unknown variables like field.
  • Harshal Jain Profile Picture
    162 on at
    Hi Martin,
     
    Please find the whole code
     
    SecurityLicenseRole        role;
    public void clicked()
    {
                super();
                int                                         recordsCount,i;
                str                                         userNameCon,UserLicenseCon,results;
                
                container                                   conUser,conLicense,record;
                UserLicenseView                             userLicenseView;
               
                Args        args = new Args();
    
                recordsCount = LicenseTmp_DS.recordsMarked().lastIndex();
                LicenseTmp =  LicenseTmp_DS.getFirst(1);
    
                while(LicenseTmp)
                {
                    conUser = conIns(conUser,1,LicenseTmp.Id );
                    conLicense = conIns(conLicense,1,LicenseTmp.License);
    
                    LicenseTmp = LicenseTmp.getNext();
                }
    
                record = conIns(record,1,conUser);
                record = conIns(record,2,role);
                record = conIns(record,3,LicenseField.valueStr());
    
                results = con2Str(record,',');
                args.parm(results);
    
    
                MenuFunction    menuFunction;
                menuFunction = new MenuFunction(menuitemActionStr(LicenseBasis), MenuItemType::Action);
                menuFunction.run(args);
    }
     
  • Suggested answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at
    I'm sorry, but I can't execute your code, because depends on some form context, such as a form data source.
     
    But I think I see the source of your bug. Unlike your code, the following snippet can be pasted to runnable class and executed, so you can see the result for yourself.
    SecurityLicenseRole role;
    con2Str([role], ',');
    You can see that most of code you gave us is irrelevant to the problem - you didn't do enough work on bug isolation. You didn't even correctly identify the place where the error is thrown, which is necessary to understand and resolve the issue.
     
    The problem is that some values you're trying to convert to a string with comma-separated values aren't primitive. You should convert them to a string before passing the container to con2str() - or maybe the whole idea of converting this data to a string is wrong.
  • Verified answer
    Harshal Jain Profile Picture
    162 on at
    Hi , 
    So passing the role to container was error. Instead i used this and it worked- 
     
    args.record(role);
     

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 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans