Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to set cursor posi...
Finance forum

How to set cursor position to the marked record where checkbox mark is a unbound control on a form

Posted on by 7
Hi there,
 
My requirement is i have created a form similar to form "Copy all" in sales orders form. When i open that form it will show two grids one for sales header and another for respective sales lines and I have added two unbound checkbox controls "Header selected" & "Lines selected" on both header and lines grid for selecting of header and lines for further process.
 
1. If i mark "Header selected" then automatically sales lines related to that sales order should automatically get marked on "Lines selected"  
2. If i mark another "Header selected" on sales header grid then the previous record "header selected" & "Lines selected" should get unmark and the new "Header selected" and "Lines selected" should mark
3. I achieved both the above functionalities by using edit methods to both check boxes and storing values in a maps 
4. To unmark the previous selected record and mark the newly selected one, i have used "modified" method of "Header selected" checkbox on header 
5. The issue that I'm facing is after previous record is unmarked I'm doing form refresh using "Task refresh" and I have written the code to mark new record but "the cursor is not staying at the newly marked record instead it moves to the last record in the grid as i have given form datasource property "Start position" as "Last".
6. I want to know how to set the cursor position on the newly marked record. Any help would be appreciated.
 
I have tried below ways to set the cursor position in modified method of "Header selected" check box control but not succeeded
1. int position;
   position = SalesTable_ds.getPosition();  
   custom code to unmark previous record
   super();
   refresh using task refresh
   SalesTable_ds.setPosition(position);
   custom code to mark newly selected record on both header and lines 
2. SalesTable salesTableLoc, tmpTable;
    salesTableLoc = SalesTable_ds.cursor();
    RecId recId = salesTableLoc.Recid
    tmpTable = SalesTable::findRecId(tmpTable)
    custom code to unmark previous record
    super();
    refresh using task refresh
    SalesTable_ds.findRecord(tmpTable);
    custom code to mark newly selected record on both header and lines
 
  

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans