web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

X++ select not picking up record

(0) ShareShare
ReportReport
Posted on by 110

Hi all, 

Hoping you can help - I'm very new to X++ and I have the following:

WorkflowTrackingStatusTable workflowTrackingStatusTable;
        WorkflowTrackingTable workflowTrackingTable;
        WorkflowStepEntity workflowStepEntity;

        select firstonly1 workflowTrackingStatusTable
            join WorkflowTrackingTable
            join workflowStepEntity
            order by WorkflowTrackingTable.TrackingDateTimeTickCount desc
            where workflowTrackingStatusTable.ContextTableId == _tableId
            && workflowTrackingStatusTable.ContextCompanyId == _companyId
            && workflowTrackingStatusTable.ContextRecId == _recId
            && workflowTrackingStatusTable.RecId == workflowTrackingTable.WorkflowTrackingStatusTable
            && workflowTrackingTable.ElementId == workflowStepEntity.ElementId
            ;

        PositionHierarchy positionHierarchy;

        str depot = PositionHierarchySupport::GetDepot(_tableId, _recId);
            
        select positionHierarchy
                where positionHierarchy.WorkflowLevel == workflowStepEntity.ParticipantTokenName
                && positionHierarchy.Depot == depot
                ;

        if (positionHierarchy.RecId)
        {
            POSITIONHIERARCHYLIMITS positionHierarchyLimits;

            select positionHierarchyLimits
                where positionHierarchyLimits.WorkflowLevel == positionHierarchy.WorkflowLevel
                && positionHierarchyLimits.WorldTerritory == positionHierarchy.WorldTerritory
                ;

            if (positionHierarchyLimits.RecId)
            {
                return positionHierarchyLimits.ApprovalAmount;
            }
        }
                
        return (0);


The first two selects work as expected but the third (on PoistionHierarchyLimits) doesn't return anything, even though I run the query in SQL and it's fine.

Any idea on what I'm missing here, I'm going a bit mad with it :-\

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,284 on at

    Hi leddy365,

    You can do 

    select generateonly positionHierarchyLimits
        where positionHierarchyLimits.WorkflowLevel == positionHierarchy.WorkflowLevel
           && positionHierarchyLimits.WorldTerritory == positionHierarchy.WorldTerritory;
    info(positionHierarchyLimits.getSQLStatement());


    To get actual SQL statement and find out what is wrong with it.


  • Verified answer
    leddy365 Profile Picture
    110 on at

    Thanks ievgen for the reply - I got it sorted in the end, it was nearly 2am here and I obviously needed sleep as I was querying the wrong Company... :-S

    I didn't know about  .getSQLStatement() so it was worth the post for that :) Thanks again

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans