Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Update Customer using Aif document service classes in x++

Posted on by Microsoft Employee

Hi Everyone,

When updating customer details using custcustomerservice  class (AIF) in X++, i am getting this error.

AOF-error.png

Please give me idea to solve the above Error.

 

Thanks & Regards,

Murali.

*This post is locked for comments

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Update Customer using Aif document service classes in x++

    I'm not sure what could help. What looks a bit suspicious is that you put the same time in all parameters:

    - Valid from

    - Valid to

    - Valid as of date

    I'm not sure what you expect as a result.

    Anyway, perhaps you could look at this old thread, where the same issue is discussed, and also a solution is provided: community.dynamics.com/.../how-to-update-customer-details-in-ax-by-using-aif-in-c

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Update Customer using Aif document service classes in x++

    Yes, Nikolaos

    please check and advise me.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Update Customer using Aif document service classes in x++

    So that is the exact code that gives you the error?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Update Customer using Aif document service classes in x++

    Hi Nikolaos,

    Thanks for your response and please find the below code.  

       #define.Accountnum("Cust-209")

       #define.Name("AX7 Introduction DevelopmentI")

       #define.CustGroup("30")

       #define.Currency("USD")

       CustCustomerService             service;

       CustCustomer                    document1;

       CustCustomer_CustTable          dataObject;

       AxdCustomer                     UpdateCustomer;

       CustTable                       custtable;  

       String30                        id;

       Map                             map;

       AifEntityKey                    key             = new AifEntityKey();

       AifEntityKeyList                entityKeyList   = new AifEntityKeyList();

       AxdEntityAction                 entityAction =  AxdEntityAction::update;

       str getHashCode(String30  _Accountnum)

       {

           AxdBaseRecordInfo       recordInfo;

           str                     documentHash;

           Map                     dataSourceMap = new Map(Types::Integer,Types::Integer);

           select  custtable

               where custtable.AccountNum ==  _Accountnum;

           recordInfo  = AxdBaseRecordInfo::newCommon(custtable,1 , dataSourceMap);

           documentHash    = recordInfo.getRecordHash();

           return documentHash;

       }

       void getDocumentData()

       {

           document1 = new CustCustomer();

           document1.createCustTable();

           dataObject = document1.parmCustTable().addNew();

           if (entityAction == AxdEntityAction::update)

           {

               dataObject.parm_DocumentHash(getHashCode(#Accountnum));

           }

           dataObject.parmAccountNum(#Accountnum);

           dataObject.parmCustGroup(#CustGroup);

           dataObject.parmCurrency(#Currency);

       }

       service = CustCustomerService::construct();

       UpdateCustomer  =  new AxdCustomer();

       if (entityAction == AxdEntityAction::update)

       {

           getDocumentData();

       }

       map = new Map(Types::Integer, Types::Container);

       map.insert(fieldnum(CustTable, AccountNum), [#Accountnum]);

       key.parmTableId(tablenum(CustTable));

       key.parmKeyDataMap(map);

       entityKeyList.addEntityKey(key);

       UpdateCustomer.createEntityKey(custtable,map);

       UpdateCustomer.parmValidAsOfDateTime(DateTimeUtil::utcNow());

       UpdateCustomer.parmValidFromDateTime(DateTimeUtil::utcNow());

       UpdateCustomer.parmValidTimeStateType(AxdValidTimeStateType::AsOf);

       UpdateCustomer.parmValidToDateTime(DateTimeUtil::utcNow());

       service.update(entityKeyList, document1);        

    thanks and regards,

    Murali.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Update Customer using Aif document service classes in x++

    Perhaps you could share your code? It's always easier to see what's wrong if it's possible to see the code :)

    Do you get the error when selecting the customer, or updating it?

    Anyway, perhaps you can use CustCustomer.parmValidAsOfDateTime to provide the required parameter.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans