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();
  • Verified answer
    Harshal Jain Profile Picture
    Harshal Jain 162 on at
    How to pass the container in arguement?
    Hi , 
    So passing the role to container was error. Instead i used this and it worked- 
     
    args.record(role);
     
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 231,403 Most Valuable Professional on at
    How to pass the container in arguement?
    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.
  • Harshal Jain Profile Picture
    Harshal Jain 162 on at
    How to pass the container in arguement?
    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);
    }
     
  • Martin Dráb Profile Picture
    Martin Dráb 231,403 Most Valuable Professional on at
    How to pass the container in arguement?
    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
    Harshal Jain 162 on at
    How to pass the container in arguement?
    Hi Martin
    I am getting an error at -
     
    args.parm(results);
  • Martin Dráb Profile Picture
    Martin Dráb 231,403 Most Valuable Professional on at
    How to pass the container in arguement?
    Okay, now please tell us which of the calls throws the exception.
  • Harshal Jain Profile Picture
    Harshal Jain 162 on at
    How to pass the container in arguement?
    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
    Martin Dráb 231,403 Most Valuable Professional on at
    How to pass the container in arguement?
    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans