Skip to main content
Dynamics 365 Community / Forums / Finance forum / How to integrate method?
Finance forum
Suggested answer

How to integrate method?

editSubscribe (1) ShareShare
ReportReport
Posted on by 20
Hello, I would like to integrate Method B in Method A in ordert to decrease run time. How can I integrate or decrease run time?
In the real code there are more conditions that decude the EDT D value. 
Method A calls Method B the number of records imported by the user.

private void MethodA()
    {
TmpTableA.linkPhysicalTableInstance(TmpTableB);
while select
    Field1,           
    Field2,            
from
    TmpTableA
order by
    TableA.Field3,
outer join
    Field3
from
    View
where
    View.Field1 == TmpTableA.Field1
{
    str field1_val = TmpTableA.Field1;          
    str field2_val = TmpTableA.Field2;                  
    str field3_val = View.Field3;          

    if(condition)
    {
        number = X;
    }
    else if (condition)
    {
       number = Y;
    }
    this.MethodB(
        field1_val, 
    number);
}

 private void MethodB(EDTString C,
                                  EDTString D)
    {
        while select forupdate TmpTableB
            where TmpTableB.Field1 == C
        {
            TmpTableB.Number = D;
            TmpTableB.Type = Update;
            TmpTableB.update();
        }
Attachments
  • Waed Ayyad Profile Picture
    Waed Ayyad 2,076 on at
    How to integrate method?
    Hi,

    Is your issue resolved? If yes, mark the answers that helped you as verified.


    Thanks
    Waed Ayyad
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,076 on at
    How to integrate method?
    Hi,
     
    I think you can use update_recordset on the method B. Did you try it? 
     
    Check the below code it maybe helpful for you:
    private void MethodB(EDTString C, EDTString D)
        {
           update_recordset TmpTableB 
           setting
              TmpTableB.Number = D,
              TmpTableB.Type = Update
           where TmpTableB.Field1 == C;
         }
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Community member Profile Picture
    Community member 20 on at
    How to integrate method?
    Thank you Waed,
    I would like to integrate method B in order to change update to update_recordset.
    I omitted some lines. The lines that you mentioned are used in other conditions.  
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,076 on at
    How to integrate method?
    Hi,
     
    What do you mean by integrate Method B in Method A? Do you to remove the Method B Call?  Usually, the method should do one functionality, In case the method will do more than one functionality you should split it to different methods, so I think it's better to keep the method B. 
     
    What is the usage of the following lines?
     
      str field1_val = TmpTableA.Field1;          
      str field2_val = TmpTableA.Field2;                  
      str field3_val = View.Field3;      
     
    You can call the Fields directly without assigning it to new variables.
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
      
  • Suggested answer
    Judy Profile Picture
    Judy Microsoft Employee on at
    How to integrate method?
    Hi, by integrating Method B directly into Method A, you eliminate the need for a separate method call and reduce the overall run time. 
    // Integrate Method B here
    while select forupdate TmpTableB
    where TmpTableB.Field1 == field1_val
    {
    TmpTableB.Number = number;
    TmpTableB.Type = Update;
    TmpTableB.update();
    }
    }

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,183 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,733 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans