Skip to main content

Notifications

Announcements

No record found.

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 230,433 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 230,433 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans