5

Fellow developers, I have a custom list page, where a user can select few records, hit a button in Action pane that runs some logic in a class, and all that works fine. My problem is that the cursor does not stay at the same record but goes to the top of the grid. Sounds like a familiar issue?

I store the FormDataSource of the list page using args in the custom class that has all the logic.

I tried few things but none worked.

  1. formDataSource.research(true) True parameter is supposed to retain the position after research does its job. I am guessing this should have been the most straightforward solution. List page query has 2 datasources joined using Outer join and my guess is research(true) works only with Inner joins.

  2. formDatasource.setPosition(position)

    int position;
    position = formDatasource.getPosition();

    formDatasource.research();

    formDatasource.setPosition(position);

    I store the position using getPosition and set it again using setPosition. No use.

  3. formDataSource.findRecord()

    currentRecord = formDatasource.cursor();

    recId = currentRecord.RecId;
    formDatasource.reread();

    formDatasource.research();
    formDatasource.findRecord(currentRecord);

    i use the ds.cursor() to get the current record and pass it to findRecord() after research(). No use.

  4. formDataSource.findValue()

    currentRecord = formDatasource.cursor();

    recId = currentRecord.RecId;
    formDatasource.reread();

    formDatasource.research();
    formDatasource.findValue(fieldNum(Table, RecId), int642str(recId));

    i use the ds.cursor() to get the current record and recId and pass it to findValue() after research(). No use.

I debugged the above code and the cursor() method does get the current record and its recId. I have started to believe that it might be a limitation of list page, and praying that somebody proves me wrong.

Any help is appreciated.

Harry
  • 145
  • 1
  • 4
  • 13
  • Can you also try by using the task macro and call the #taskF5 to refresh the form. This results same as clicking the refresh button on list pages. you can refer to http://msdn.microsoft.com/en-us/library/hh812104.aspx for more details. – Rachit Garg Jul 18 '13 at 05:40
  • 'research' has an optional boolean parameter to retain the position in the grid. For an excellent overview see http://kashperuk.blogspot.com.es/2010/03/tutorial-reread-refresh-research.html – ian_scho Dec 07 '13 at 08:39

3 Answers3

2

Use Method 3 but like this.

YourTable tmpTable;


currentRecord = formDatasource.cursor();

recId = currentRecord.RecId;
tmpTable = TmpTable::findByRecId(recId);
 formDatasource.reread();

formDatasource.research();
formDatasource.findRecord(tmpTable); 

Hope this helps.

Jes Gudiksen
  • 442
  • 2
  • 7
  • 16
  • //just set the recId of the tmpTable-Buffer: JUW_tmpCostCalculation positionDummy; ; positionDummy.recId = JUW_tmpCostCalculation.recid; JUW_tmpCostCalculation_DS.research(); JUW_tmpCostCalculation_DS.findRecord(positionDummy); – A. K-R Mar 19 '14 at 14:07
0

Try to pass "true" as a parameter for the research method. salesLine_ds.research(true) works in my case, i.e. if I research the line, cursor stays on the same line.

Vitaly Borisov
  • 1,133
  • 2
  • 13
  • 20
0

use the second method like this

int position;
position = formDatasource.getPosition();
//Make your update operations here
formDatasource.research(true);

formDatasource.setPosition(position);

It works for me.