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

  • Verified answer
    Martin Dráb Profile Picture
    231,994 Most Valuable Professional on at
    RE: How to insert Multi select values in detail transaction form

    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.

  • Laraib Profile Picture
    131 on at
    RE: How to insert Multi select values in detail transaction form

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

  • Martin Dráb Profile Picture
    231,994 Most Valuable Professional on at
    RE: How to insert Multi select values in detail transaction form

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

    I have comment SysTableLookup  but it giving same error

  • Martin Dráb Profile Picture
    231,994 Most Valuable Professional on at
    RE: How to insert Multi select values in detail transaction form

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

    Thanks for guiding.

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

  • Martin Dráb Profile Picture
    231,994 Most Valuable Professional on at
    RE: How to insert Multi select values in detail transaction form

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

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…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans