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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Error when using postionToRecord() and postionToRecordByValue() methods

(0) ShareShare
ReportReport
Posted on by
Hi All,
 
I had a requirement to develop an extension to the PurchReqTable form to give users a new column that showed the total amount of the Purchase Requisition on the HeaderGrid. This field should be filterable and hence I did not create a simple display method.
 
I created 2 views, one to get the sum of all charges for a PurchReqLine (PurchReqLineChargeTotalsView) and another to sum the line amount from PurchReqLine and the corresponding charges for the lines (PurchReqTableTotalsView). The PurchReqTableTotalsView leveraged the PurchReqLineChargeTotalsView to get me the required totals.

The PurchReqTableTotalsView was then added to the form extension and joined using the below code 
 
[ExtensionOf(formDataSourceStr(PurchReqTable,PurchReqTableTotalsView))]
internal final class PurchReqTable_PurchReqTableTotalsView_DS_Extension
{
    public void init()
    {
        next init();
        this.queryBuildDataSource().addLink(fieldNum(PurchReqTable, RecId), fieldNum(PurchReqTableTotalsView, RecId));
    }

}
 
This approach was working but it was noticed that when you would refresh the screen on the Details Page when viewing a specific Purchase Requisition, the requisition being displayed would get switched to the last PR in the table. To fix this the below code was used.
 
[ExtensionOf(formDataSourceStr(PurchReqTable,PurchReqTable))]
internal final class PurchReqTable_DS_Extension
{
    public void executeQuery()
    {
        
        PurchReqTable purchReqTable = this.cursor();
        RecId purchReqRecId = purchReqTable.RecId;
        FormTabPageControl tabPageDetails =  this.formRun().design().controlName(formControlStr(PurchReqTable,TabPageDetails));

        next executeQuery();

        if ( purchReqRecId && tabPageDetails.isActivePage())
        {
            purchReqTable = PurchReqTable::find(purchReqRecId);
            this.positionToRecord(PurchReqTable);
        }
        
    }

}
This solution worked for a few weeks and is now throwing the error 'Unsupported datasource used for PositionToRecord or PositionToRecordByValue. Unable to execute fallback logic to find record.' and the switching behavior on clicking the highlighted refresh button has returned. 
 
Does anyone know how to address this issue or if I should change my approach completely.
Categories:
I have the same question (0)

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 673 Super User 2026 Season 1

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 673 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 391 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans