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++ Get Production Unit of a Production Order

(0) ShareShare
ReportReport
Posted on by 1,214

Hi,

I'd like to get the Production Unit of a Production Order from Applicable resources form as in screenshot below:

2844.produnit.png

The form path is Production Order -> Production route -> Applicable resources.

The query in Applicable resources form starts with WrkCtrTable so I figured I need to join WrkCtrTable from ProdRoute but I couldn't find the correct relation between these two tables anywhere.

That's weird. I don't see any other way to get to the Production Unit. 

Has anyone ever done this? 

Thank You.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi HAIRUL HAZRI!

    The Production Unit field it's a field from WrkCtrTableIndividualView view. This view joined to WrkCtrTable.

    Screen-Shot-2018_2D00_10_2D00_02-at-11.29.53.png

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Rustem Galiamov,

    Yes, I'm aware of that. My problem is I couldn't see how can I join WrkCtrTable from ProdRoute even though the Applicable resources form is called directly from Production route form.

    From Production Route form, I did find following relations:

    ProdRoute -> WrkCtrProdRouteActivity -> WrkCtrActivity -> WrkCtrActivityRequirementSet

    But from WrkCtrActivityRequirementSet I didn't find the relation to WrkCtrTable.

    Any idea?

    Best Regards.

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    There is no relation between WrkCtrActivityRequirementSet and WrkCtrTable.

    When you open Applicable resources form from Production Route form the init() method of WrkCtrActivityRequirementSet DS adding a link between caller record and WrkCtrActivityRequirementSet in Applicable resources form:

    Screen-Shot-2018_2D00_10_2D00_02-at-13.17.01.png

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    You're right I can see that. But then how can I join from ProdRoute to WrkCtrTable and WrkCtrTableIndividualView?

    Do you know any workaround?

  • Rustem Galiamov Profile Picture
    8,072 on at

    I think there is no direct link between ProdRoute and WrkCtrTable.

    This is the generated query when you open the form from ProdRoute:

    SELECT * FROM WrkCtrTable(WrkCtrTable_1) WHERE ((IsIndividualResource = 1)) 
    EXISTS JOIN * FROM WrkCtrResourceGroupResource(WrkCtrResourceGroupResource_1)         
        WHERE WrkCtrTable.WrkCtrId = WrkCtrResourceGroupResource.WrkCtrId 
    EXISTS JOIN * FROM WrkCtrResourceGroup(WrkCtrResourceGroup_1) 
        WHERE WrkCtrResourceGroupResource.ResourceGroup = WrkCtrResourceGroup.RecId 
          AND ((SiteId = N'Общий')) AND ((IsWorkCell = 0)) 
    JOIN * FROM WrkCtrTableIndividualView(WrkCtrTableIndividualView_1) 
        ON WrkCtrTable.WrkCtrId = WrkCtrTableIndividualView.WrkCtrId 
        AND ((ValidFrom<={ts '2018-10-02 00:00:00.000'})) AND ((ValidTo>={ts '2018-10-02 00:00:00.000'}))
  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hmm now that makes it even more weird. How can the form possibly get the Applicable resources when it has no relation with ProdRoute in the first place?

    Is there any workaround for this? I just want to get the Production unit(s) given a Production Order number (ProdId).

    I don't see any other way I can do it.

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Applicable resources depends from Resource requirements (Resource requirements tab in Production Route form).

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Okay that's new. Can you elaborate more? 

    So I was referring this link to get the Resource requirements. But then still, I don't see any way I can relate the record to the Applicable resources.

    How exactly does the Applicable resources depend on Resource requirements?

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    You can set breakpoint to the WrkCtrApplicableResourceQuery class query() method and you will see how query will be generated when you open Applicable resources form from Production Route form.

  • Verified answer
    HAIRUL HAZRI Profile Picture
    1,214 on at

    I discovered that the following query works. It's the continuation from the Resource requirement job from the link in my previous comment. For now, this solves my problem.

    static void ProdRoute_Resources(Args _args)
    {
        ProdRoute                       prodRoute;
        RecId                           activityRequirementSetRecId;
        WrkCtrActivityRequirementEdit   requirementEdit;
        ProdId                          prodId = "GF-BO-000100";
        WrkCtrActivityRequirementType   relationShipType;
        WrkCtrActivityRequirement       wrkCtrActivityRequirement;
        WrkCtrCapability                wrkCtrCapability;
        WrkCtrCapabilityResource        wrkCtrCapabilityResource;
        WrkCtrTableIndividualView       wrkCtrTableIndividualView;
    
        while select prodRoute
            where prodRoute.ProdId == prodId
        {
            activityRequirementSetRecId = prodRoute.activityRequirementSet().RecId;
    
            select WrkCtrActivityRequirement
                where WrkCtrActivityRequirement.ActivityRequirementSet == activityRequirementSetRecId;
            requirementEdit =  WrkCtrActivityRequirement.requirementEdit();
            relationShipType = WrkCtrActivityRequirement.RelationshipType;
    
            info(strFmt("%1, %2",relationShipType, requirementEdit));
    
            
            while select wrkCtrCapability where wrkCtrCapability.Name == requirementEdit
                join wrkCtrCapabilityResource where wrkCtrCapabilityResource.Capability == wrkCtrCapability.RecId
                join WrkCtrId,ProdUnitId from  wrkCtrTableIndividualView
                group by wrkCtrTableIndividualView.ProdUnitId
                where wrkCtrTableIndividualView.WrkCtrId == wrkCtrCapabilityResource.WrkCtrId
            {
                info(strFmt("%1", wrkCtrTableIndividualView.ProdUnitId));
            }
        }
    }


    Thank you for pointing out that WrkCtrApplicableResourceQuery class. I can use it to double confirm my findings. Cheers :)

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