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

I'm trying to add multiple values to a single field in a range

(0) ShareShare
ReportReport
Posted on by 65

Currently, I have a list of strings that represent SiteId's

I'm trying to think of a way to insert the values into the QueryBuildRange.value() property.

QueryBuildRange.value(listObject) does not work as it only expects one string.

I was thinking I could iterate through the list but I figured I might have to create a new QueryBuildRange object each time as I don't think there's an addEnd() method like there are for lists.

Then I'd have to bring the values from each together. 

If I'm wrong please explain

Thanks!

P.S. here is my code

        while select SiteId from siteToUser where curUserId() == siteToUser.user
        {
            siteList.addEnd(siteToUser.SiteId);
        }
        sysTableLookup = SysTableLookup::newParameters(tableNum(InventSite),_lookup);

        qbds = query.addDataSource(tableNum(InventSite));
        qbr = qbds.addRange(fieldNum(InventSite, SiteId));
        qbr.value();

I have the same question (0)
  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    You can add that SiteToUser table with InventSite table using join in the lookup query itself.

    Try to avoid while select.

    sysTableLookup = SysTableLookup::newParameters(tableNum(InventSite),_lookup);
    qbds = query.addDataSource(tableNum(InventSite));
    qbds1 = qbds.addDatasource(tablenum(SiteToUser));
    qbds1.relations(true);
    qbds1.addrange(fieldnum(SiteToUser, User)).value(queryvalue(curUserId()));
    

    Thanks,

    Girish S.

  • JGjinx321 Profile Picture
    65 on at

    Thank you Girish.

    What is the problem with while selects though? Or was it just the way I was using it?

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    You were using it incorrectly, while select or select statement is not required in queries.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    You can use while select also but it not needed for your case. You are using wrongly. Check below code.

    sysTableLookup = SysTableLookup::newParameters(tableNum(InventSite),_lookup);
    
    qbds = query.addDataSource(tableNum(InventSite));
    qbr = qbds.addRange(fieldNum(InventSite, SiteId));
    while select SiteId from siteToUser where curUserId() == siteToUser.user
    {
        qbr.value(queryvalue(queryrangeconcat(siteToUser.SiteId)));
    }

    If you are using list, you need to loop through the list using ListEnumerator and use queryRangeConcat function to merge SiteId values to query range.

    ListEnumerator listEnumerator;
    while select SiteId from siteToUser where curUserId() == siteToUser.user
    {
        siteList.addEnd(siteToUser.SiteId);
    }
    sysTableLookup = SysTableLookup::newParameters(tableNum(InventSite),_lookup);
    
    qbds = query.addDataSource(tableNum(InventSite));
    qbr = qbds.addRange(fieldNum(InventSite, SiteId));
    listEnumerator = siteList.getEnumerator();
    while(listEnumerator.moveNext())
    {
        qbr.value(queryValue(queryrangeConcat(listEnumerator.current())));
    }

    Thanks,

    Girish S.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans