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

Convert code in D365Fo

(0) ShareShare
ReportReport
Posted on by 1,215

Hi all,

below code i want to convert as a X .

SELECT FIRSTFAST FORUPDATE CompanyId, Id, Partition, Status, UserId, DueDateTime, Subject, UserId, createdDateTime, Queue, RefRecId, 
RefTableId, CompanyId, ConfigurationId, Status, ElementId, MenuItemName, CorrelationId, Description 
FROM WorkflowWorkItemTable(WorkflowWorkItemTable) ORDER BY WorkflowWorkItemTable.createdDateTime DESC
WHERE ((Status = 0)) AND (((currentUserId()))) 
JOIN FORUPDATE Document, DocumentType, Originator 
FROM WorkflowTrackingStatusTable(WorkflowTrackingStatusTable) 
ON WorkflowWorkItemTable.CorrelationId = WorkflowTrackingStatusTable.CorrelationId 
OUTER JOIN FORUPDATE Name FROM WorkflowWorkItemQueue(WorkflowWorkItemQueue) 
ON WorkflowWorkItemTable.Queue = WorkflowWorkItemQueue.RecId 
OUTER JOIN FORUPDATE CompanyInfo 
FROM WorkflowQueueDocumentCommonFields(WorkflowQueueDocumentCommonFields) 
ON WorkflowWorkItemTable.RecId = WorkflowQueueDocumentCommonFields.WorkflowWorkitem

Thanks 

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: Convert code in D365Fo

    Many thanks sir, I learned one thing. :)

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Convert code in D365Fo

    Hi Riyas,

    1. forupdate should be placed for the table buffer you are trying to update. In your case, if it is workflowTrackingStatusTable, you should have this clause for this buffer only (like you have done).

    2. It should be like this - 

    where (workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending && workflowWorkItemTable.UserId == CurUserId())

    For the table buffer workflowWorkItemTable, you don't need to list the fields since you have so many fields selected. You can have the statement like this - 

    while select forupdate workflowWorkItemTable 
        order by workflowWorkItemTable.CreatedDateTime desc

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: Convert code in D365Fo

    Thanks sir, I got it,

    same I did it

    i have a two doubt.

    1. same one forupdate is enough. or without join forupdate it will work ?

    2. WHERE ((Status = 0)) AND (((currentUserId())))  i need to know same i did in x its correct or wrong below my code.

     while select forupdate CompanyId, Id, Partition, Status, UserId, DueDateTime, Subject, UserId, createdDateTime, Queue, RefRecId,
                    RefTableId, CompanyId, ConfigurationId, Status, ElementId, MenuItemName, CorrelationId, Description
                    from workflowWorkItemTable order by workflowWorkItemTable.CreatedDateTime desc
                    where (workflowWorkItemTable.Status == 0 && CurUserId())
                    join forupdate Document, DocumentType, Originator
                    from workflowTrackingStatusTable
                    where WorkflowWorkItemTable.CorrelationId == WorkflowTrackingStatusTable.CorrelationId
                    outer join forupdate Name from workflowWorkItemQueue
                    where workflowWorkItemTable.Queue == workflowWorkItemQueue.RecId
                    outer join forupdate CompanyInfo
                    FROM workflowQueueDocumentCommonFields
                    where WorkflowWorkItemTable.RecId == workflowQueueDocumentCommonFields.WorkflowWorkitem
                {
                
                }

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Convert code in D365Fo

    I am not sure if I have seen FIRSTFIRST and FORUPDATE keywords being used in SQL. The ON keyword will be replaced by where in X++, AND will replaced by && and instead of "=" you should use "==".

    Try making these changes and check if it works.

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: Convert code in D365Fo

    Thanks for replay sir,

    no sir still it has SQL and i want to as a X++ like Etc: keyword "On", "And".

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Convert code in D365Fo

    Hi Riyas,

    This looks like an X++ statement. What are you looking to convert here?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March 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... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,017 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans