Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

How to initialize field with constant value using Query::insert_recordset

(1) ShareShare
ReportReport
Posted on by
Hi experts,
 
I have a table A that has a field named sessionId.
For some reasons, I have to use Query to insert multiple records into table A.
Some field of table A are mapped with field from other tables.
But for sessionId, I need to set a constant value for it.
 
So is there a way to initialize field sessionId with a constant value using Query::insert_recordset()?
Or I can only insert other fields firstly, and then use update_recordset to set the field sessionId?
 
Thanks.
  • Martin Dráb Profile Picture
    Martin Dráb 231,430 Most Valuable Professional on at
    How to initialize field with constant value using Query::insert_recordset
    Your (verified) answer claims that it's impossible and the records must be updated later, while my reply does offer a solution for Query::insert_recordset().
  • Verified answer
    Kai Cheng Profile Picture
    Kai Cheng on at
    How to initialize field with constant value using Query::insert_recordset
    Now the only way I found is that:
    Insert recordset firstly, then update_recordset for the records just insert with the constant values.
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 231,430 Most Valuable Professional on at
    How to initialize field with constant value using Query::insert_recordset
    I suspect you can't use a literal value instead of a field mapping. At least Microsoft thought so when creating RetailTmpCDXNodeConstTable table. It's a TempDB table that they populate with constant values they want in Query::insert_recordset(), add it to the query and use normal field mapping to take values from RetailTmpCDXNodeConstTable insert to the target table. Maybe you can use the same approach.

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,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans