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 insert Multi select values in detail transaction form

(0) ShareShare
ReportReport
Posted on by 131

I have created Detail Transaction Form. In which I have added multi select lookup but issue is when i open lookup or press ok button of lookup Dynamics Ax 2012 forcedly close.

I am aware of Detail Transaction Form's grid behavior that it by default insert record in table but what I want is that grid create numbers of record in table according to the number of selected value of multi select lookup.

Here is the lookup code below:

public void lookup()
{
	Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    SysTableLookup sysTableLookup;
    str ItemCategoryCodeforlockup = RNI_SchemeLinesDetailTable_Product.valueStr();

    sysTableLookup = SysTableLookup::newParameters(tableNum(SL_ItemCatSubType), this);
    queryBuildDataSource = query.addDataSource(tableNum(SL_ItemCatSubType));
    queryBuildDataSource.addRange(fieldNum(SL_ItemCatSubType,RNI_LINEOFPRODDESCRIPTION)).value(ItemCategoryCodeforlockup);

    sysTableLookup.parmQuery(query);
    sysTableLookup.addLookupField(fieldNum(SL_ItemCatSubType, Description));
    sysTableLookup.addLookupField(fieldNum(SL_ItemCatSubType, Itemcategorycode));
    sysTableLookup.performFormLookup();

    msCtrl = SysLookupMultiSelectCtrl::constructWithQuery(this.formRun(),this,query);  
}

public boolean modified()
{
	boolean ret;

	container c,v;
	int i;
	ret = super();
	
	if (ret)
	{
		c = msCtrl.get();  // get RecIds of the selected rows
		v = msCtrl.getSelectedFieldValues(); // get actual value of the selected rows

		for (i = 1; i <= conLen(c);i  )
		{
			//info(conPeek(c,i));
			//info(conPeek(v,i));
		}
	}

	return ret;
}

Below is the error screen shots

multiselect

multiselect

I have the same question (0)
  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Try debugging yourr code and finding at which line it crashes.

  • Laraib Profile Picture
    131 on at

    Thanks for guiding.

    I have debugged code but when I select lookup value it crashes without going to code

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    I think I see the bug. You're trying to create two lookups at once - one with SysTableLookup and another with SysLookupMultiSelectCtrl.

  • Laraib Profile Picture
    131 on at

    I have comment SysTableLookup  but it giving same error

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Please show us your new code and tell us the type of control whose lookup() control you've overriden.

    Also, I hope tnat you aren't trying to store multiple values in a single table field, because that would be a very bad idea.

  • Laraib Profile Picture
    131 on at

    Yes Martin,  I am trying to insert multiple values in single table. Its client requirement

  • Verified answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    You can have mutliple values in a single table - simply create a mutliple rows.

    But if you want to insert multiple comma-separated values to a single table field, then it's a bug. Note that end users are not software architects and you can't expect from them to do now how to do it. It's your job to find a meaningful technical solution for their business requirements.

    Putting multiple values to the same field would be so big flaw that it's forbidden already by the first normal form of database design. It has many problems. For example:

    1. You can't meaningfully query the field. For example, you can't find if the fields contains an element called "abc". All you can do is checking if it contains such a string, but it's slow and it may return different data that you wants.
    2. You can't index the content, therefore finding values will end up with full-table scans.
    3. You can't set a meaningful lenght of the field.

    The right approach is different. Create a new table related to the main one and create a row there for each value. For example, instead of having "A,B,C" in a single field, you'll have three rows in a table. In your case, you'll store a reference to the main table and an ID from SL_ItemCatSubType table.

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