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();

  • Suggested answer
    GirishS Profile Picture
    27,823 Moderator on at
    RE: I'm trying to add multiple values to a single field in a range

    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.

  • Mohit Rampal Profile Picture
    12,556 Moderator on at
    RE: I'm trying to add multiple values to a single field in a range

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

  • JGjinx321 Profile Picture
    65 on at
    RE: I'm trying to add multiple values to a single field in a range

    Thank you Girish.

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

  • Verified answer
    GirishS Profile Picture
    27,823 Moderator on at
    RE: I'm trying to add multiple values to a single field in a range

    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.

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... 292,886 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,766 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans