Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Convert code in D365Fo
Finance forum
Answered

Convert code in D365Fo

Posted on by 1,213

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
    Riyas ahamed F 1,213 on at
    RE: Convert code in D365Fo

    Many thanks sir, I learned one thing. :)

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 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
    Riyas ahamed F 1,213 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
    Gunjan Bhattachayya 35,417 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
    Riyas ahamed F 1,213 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
    Gunjan Bhattachayya 35,417 on at
    RE: Convert code in D365Fo

    Hi Riyas,

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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,986 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans