Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Error : The value 'xxx' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I built my own report using DP, Controller and Contract class. Everything was working fine, but I have 2 parameters, Resource and ResourceGroup (both WrkCtrId type). 

The problem is when I open Controller, the combo box of parameters only displays resources (Type : Machine or Location) and no resource groups (whereas they are stored in the same table : WrkCtrTable).

So my work around was to add an UIBuilder class for my report and override the lookup and postBuildmethod, this way :

public void lookupResourceGroup(FormStringControl _formStringControl)
{    
    Query query = new Query();
    QueryBuildDataSource DataSource;    
    SysTableLookup sysTablelookup;
 
    //create a table lookup    
    sysTablelookup = SysTableLookup::newParameters(tableNum(WrkCtrTable),_formStringControl);
    sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,WrkCtrId));
    sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,Name));
    sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,WrkCtrType));
     
    //create a query
    DataSource = query.addDataSource(tableNum(WrkCtrTable));
DataSource.addRange(fieldNum(WrkCtrTable,WrkCtrType)).value(enum2str(WrkCtrType::Group));
 
    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();
}

-------------------------------------------------------------------------------------

public void postBuild()
{
    DialogField dlgCustGroup;
    
    super();
        
    dlgCustGroup = this.bindInfo().getDialogField(this.dataContractObject(),
                methodStr(DailyProdContract,parmResourceGroup));
 
    //register the method we want to override
    dlgCustGroup.registerOverrideMethod(
          methodStr(FormStringControl, lookup),
          methodStr(DailyProdUIBuilder,lookupResourceGroup),
          this);    
}


So, after I added the range to select only resource groups, it works, the comboBox displays the right values. But once I  select one I get the error "The value '***' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'."

I've put a breakpoint (in Classes\Info\add() method) to locate the cause, it looks like the exception is coming from Classes\FormStringControl\Validate().

So I have 2 questions : Why does my resource and resourceGroup parameters only looks up values of type Machine in the first place ? And how can I work around this problem?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error : The value 'xxx' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'.

    Hey Martin,

    That's exactly what I needed. Instead of WrkCtrId type, I should have used WrkCtrGroupId. Works like a charm. Thank you very much for your fast answer!

  • 5400 Profile Picture
    5400 7,162 on at
    RE: Error : The value 'xxx' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'.

    Please check the relationship between WrkCtr type and WrkCtrId during selection.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,309 Most Valuable Professional on at
    RE: Error : The value 'xxx' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'.

    Open WrkCtrId datatype in AOT and expand Table References. You'll see it has a filter 1 == WrkCtrTable.IsIndividualResource.

    If this is not what you want, then you're using a wrong datatype.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans