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)

Improve performance while retrieving selected record in form data source

(0) ShareShare
ReportReport
Posted on by

I have a case where certain  action should be performed on selected record on form  data source, the problem is that I have around 2000 selected record and so retrieving  them to apply the process takes around  25 min  , how can I improve the process of retrieving selected record from the data source ?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    You should show us your code. 25 minutes just to retreive 2000 records is too much time. Are you performing actions after retreiving the records that might take up time?

  • maram fraij Profile Picture
    on at

    I retrieve all records  then call menu action as per the code below  ; I pass them as comma separated list using arg. parm() . it takes around 25 min to display dialog appears when preform menu action .

    Args            args;

       MenuFunction    menuFunction;

       container       Con;

       str             multiSelectString;

       SitPayWorkerTimesheetTrans  localSitPayWorkerTimesheetTrans,SitPayWorkerTimesheetTransHolder;

       ;

       args = new Args();

       menuFunction = new MenuFunction(menuitemActionStr("SitPayTimesheetTransStatusChangeDetailed"), MenuItemType::Action);

       args = new Args(menuFunction.object());

       args.caller(element);

       args.record(SitPayWorkerTimesheetTrans);

       args.parmEnumType(enumnum(SitPayWorkerTimesheetTransStatus));

       args.parmEnum(SitPayWorkerTimesheetTransStatus::Transfered);

       localSitPayWorkerTimesheetTrans= SitPayWorkerTimesheetTrans_ds.getFirst(1) as SitPayWorkerTimesheetTrans;

       while (localSitPayWorkerTimesheetTrans)

       {

           // storing recid of selected record in container

           con = conIns(con,1, localSitPayWorkerTimesheetTrans.RecId);

           localSitPayWorkerTimesheetTrans= SitPayWorkerTimesheetTrans_ds.getNext()as SitPayWorkerTimesheetTrans;

       }

       // converting container to string with comma separated

       multiSelectString = con2Str(con,",");

       if (multiSelectString=="")  // nothing selected

       {

           multiSelectString=int642str(SitPayWorkerTimesheetTrans.RecId);

       }

       args.parm(multiSelectString);

       menuFunction.run(args);

  • Community Member Profile Picture
    on at

    Have a look at the MultiSelectionHelper class (you can Google examples of it). Also you always wirte on index 1 in the container which seems weird.

    Still I don't think your code should take that long. Are you sure that your code is the problem and not something thats happening in the class you call?

  • maram fraij Profile Picture
    on at

    For the last point yes I am sure is from the retrieving of the data since I measure the time util dialog message for menu action appears after clicking ok the process is applied on the logic

  • maram fraij Profile Picture
    on at

    I test ConIns function using the code below is woks fine

    container      Con;

       int             i;

       str             MultiSelect;

       for(i =1; i<=100; i++)

       {

           con = conIns(con,1, i);

       }

       MultiSelect=con2Str(con,",");

       info(MultiSelect);

       for(i =1; i<=100; i++)

       {

           info(conPeek(Con,i));

       }

    //// result

    Message (12:24:08 pm)

    100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1

    100

    99

    98

    97

    96

    95

    94

    93

    92

    91

    90

    89

    88

    87

    86

    85

    84

    83

    82

    81

    80

    79

    78

    77

    76

    75

    74

    73

    72

    71

    70

    69

    68

    67

    66

    65

    64

    63

    62

    61

    60

    59

    58

    57

    56

    55

    54

    53

    52

    51

    50

    49

    48

    47

    46

    45

    44

    43

    42

    41

    40

    39

    38

    37

    36

    35

    34

    33

    32

    31

    30

    29

    28

    27

    26

    25

    24

    23

    22

    21

    20

    19

    18

    17

    16

    15

    14

    13

    12

    11

    10

    9

    8

    7

    6

    5

    4

    3

    2

    1

  • maram fraij Profile Picture
    on at

    it seems function conIns handle this automatically if provided index is filled

  • Community Member Profile Picture
    on at

    Try to set a breakpoint on the line

    menuFunction.run(args);

    and see how long it takes to hit it.

  • Martin Dráb Profile Picture
    237,892 Most Valuable Professional on at

    How users actually select the records? Don't tell me that they pick 2000 records manually.

    If you have a query returning these records, you can pack it, send it to server and execute query there. Fetching anything through the form will be many times slower.

  • maram fraij Profile Picture
    on at

    the user filters the  records on the form  based on certain status, select them then click the button which perform the logic above

  • Martin Dráb Profile Picture
    237,892 Most Valuable Professional on at

    If you can run the logic for all filtered records (e.g. records in a particular status in your case), then use my suggestion.

    You really should base your solution on a query and not a selection, especially if you already have performance problems.

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