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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Updating table from another table

(0) ShareShare
ReportReport
Posted on by 120

Updating table from another table

 

Hi ,

This script is  displaying  the data from the Name field and not displaying data from  DISPLAYPRODUCTNUMBER   so it is displaying only the name that is from  EcoResProductTranslation Table, but it is not display  Displaying DISPLAYPRODUCTNUMBER  that is from  ECORESPRODUCT Table

For example this example from the  actual data  in the tow tables :

This Data From ECORESPRODUCT Table

DISPLAYPRODUCTNUMBER                 RECID

23022 : 100 : 43 : 11/7 :                        5637307150

23022 : 145 : 43 : 11/7 :                        5637307149

34001 : 150 : 45 : 12/12 :                      5637307148

33001 : 10 : 45 : 12/12 :                        5637307147

This Data From ECORESPRODUCTTRANSLATION Table

Name                                                RECID

SSx                                                    5637307150

SSx                                                    5637307149

M8z                                                   5637307148

M8x                                                   5637307147

This is the  result that to be update to the description filed

SSx    100*43*11/7

SSx    145*43*11/7

M8Z  150*45*12/12

M8X  10*45*12/12

-----------------------------------------------------------------------------------------------

 static void updateProductDescription(Args _args)

{

   EcoResProduct               product;

   EcoResProductTranslation    translation;

   ttsBegin;

   while select forUpdate translation

       join RecId, DisplayProductNumber from product

           where product.RecId == translation.Product

   {

       translation.Description = strFmt('%1 %2',

           translation.Name,

           strReplace(subStr(product.DisplayProductNumber, 8, 20), ':', '-'));

       print translation.Description;      

       pause;

     //  translation.doUpdate();

   }

 //  ttsCommit;

}

----------------------------------------------------------------------------

Can anyone help me how to get the  data as the above example

Best  regards

Jamil

Reply

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    I guess you just need a little help with Splitting and merging the string.

    Here, try this:

    static void Job22(Args _args)
    {

    str sourceStr = "23022 : 100 : 43 : 11/7 : ";
    str strName = 'SSx';
    container con;
    str result;

    con = str2con(sourceStr," : ");
    con = conDel(con,1,1);
    con = conDel(con,conLen(con),1);

    result = strLRTrim(strName) + " " + con2Str(con,'*');

    info(result);

    }

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    But please just try to see what results you get before updating them.

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Hi Jamil,

    [Issue Resolved now]

    I just ran your code and it actually brings the value for DisplayProductNumber from the EcoResProduct table. But when there is no character like ':' in the value, your code with strReplace function ignores the name because of that.

    I have Merged both codes together and tested with the sample data you showed. This will work for you now. Cheers!

    static void updateProductDescriptionNew(Args _args)
    {

    EcoResProduct product;
    EcoResProductTranslation translation;
    container con;
    ;
    ttsBegin;
    while select forUpdate translation
    join RecId, DisplayProductNumber from product
    where product.RecId == translation.Product
    {

    print product.DisplayProductNumber;
    //product.DisplayProductNumber = "23022 : 100 : 43 : 11/7 : ";
    if( strFind(product.DisplayProductNumber, ':', 1, strLen(product.DisplayProductNumber) ) )
    {

    con = str2con(product.DisplayProductNumber,' :');
    con = conDel(con,1,1);
    con = conDel(con,conLen(con),1);

    translation.Description = strLRTrim(translation.Name) + " " + strReplaceChars(con2Str(con,'*'),' ',0);

    }
    else
    {

    translation.Description = strLRTrim(translation.Name) + " " + strLRTrim(product.DisplayProductNumber);

    }
    print translation.Description;
    pause;
    // translation.doUpdate();

    }
    // ttsCommit;

    }

     

    Please try this code and mark the answers verified of this resolved your issue thanks.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans