Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AIF Inbound Service creates Sales Order of Journal SalesType

Posted on by 4,624

Hi,

I am creating SalesOrder using AIF inbound port via File System adapter , i just successfully done this through this  https://community.dynamics.com/ax/f/33/t/241809  but its creating salesOrder of only JournalType.

Then I changed it default sales order Type from AR parameters form but didn't work. Then I changed my data policies from AIF Inbound port and enable salesType element so i can pass salesType through Input XML massage and my xml massage is like this :

<?xml version="1.0" encoding="utf-8" ?>
<Envelope xmlns="schemas.microsoft.com/.../Message">
<Header>
<Action>schemas.microsoft.com/.../create&lt;/Action>
</Header>
<Body>
<MessageParts>
<SalesOrder xmlns="schemas.microsoft.com/.../SalesOrder">
<SalesTable class="entity">
<CustAccount>1136</CustAccount>
<DeliveryDate>2017-06-28</DeliveryDate>
<PurchOrderFormNum>PO</PurchOrderFormNum>
<ReceiptDateRequested>2017-06-28</ReceiptDateRequested>
<SalesLine class="entity">
<ItemId>6000</ItemId>
<SalesPrice>100</SalesPrice>
<SalesQty>1</SalesQty>
<SalesType>Sales</SalesType>
<SalesUnit>Quantity</SalesUnit>
</SalesLine>
</SalesTable>
</SalesOrder>
</MessageParts>
</Body>
</Envelope>

but it didn't work. Can anyone suggest please?

*This post is locked for comments

  • Rohin Profile Picture
    Rohin 4,624 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    sure Chaitanya, Now my code is looks like below:

    protected void prepareSalesTable(AxSalesTable _axSalesTable)
    {
        SalesTable              localSalesTable;
        CustTable               custTable;
        CustAccount             invoiceAccount;
    
        if (!_axSalesTable.salesTable())
        {
            createRecord = true;
           // _axSalesTable.parmSalesType(this.salesType());
            _axSalesTable.parmSalesType(salesType::Sales);  // changes here
    
            select firstonly RecId from localSalesTable
                where localSalesTable.CustAccount       == _axSalesTable.parmCustAccount()
                   && localSalesTable.PurchOrderFormNum == _axSalesTable.parmPurchOrderFormNum()
                   && localSalesTable.SalesId           != _axSalesTable.parmSalesId();
    
         /*   if (localSalesTable.RecId)
            {
                _axSalesTable.parmSalesType(SalesType::Journal);
            }*/
    
            if (localSalesTable.RecId)
            {
                _axSalesTable.parmSalesType(SalesType::Sales);  // changes here
            }
    
            if (_axSalesTable.parmInvoiceAccount())
            {
                custTable      = CustTable::find(_axSalesTable.parmCustAccount());
                invoiceAccount = custTable.InvoiceAccount ? custTable.InvoiceAccount : custTable.AccountNum;
                if (invoiceAccount != _axSalesTable.parmInvoiceAccount())
                {
                    _axSalesTable.parmSalesType(SalesType::Sales); // changes here
                }
            }
        }
        else
        {
            localSalesTable = _axSalesTable.salesTable();
            _axSalesTable.parmSalesType(salesType::Sales);  // changes here
            if(localSalesTable.hasPriceDiscChangePolicy())
            {
                localSalesTable.clearAllPriceDiscChangePolicies();
            }
        }
    }


    Thanks for help.

  • Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    Hi,

    Can you provide the resolution you have taken, it could help others if they face the same.

    Thanks,

    Chaitanya Golla

  • Rohin Profile Picture
    Rohin 4,624 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    its working now ..thanks to all

  • Verified answer
    Ajit Profile Picture
    Ajit 8,755 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    That's weird. Did you customize insert\update method of 'SalesTable'? I would debug once to check what I am getting here in above methods. Or can you check if salesType is inserted as 'Journal' or it is getting updated to 'Journal' from 'Sales order' after some process (To check this you can debug or setup temporary DB log).

  • Rohin Profile Picture
    Rohin 4,624 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    Thanks Chaitanya,

    I already setup this parameter to salesOrder but still its creating journalType order. Like i said before i changed the salesType() . Please see the below changes that i done :

    1325.4.PNG   0250.2.PNG

    3073.3.PNG1325.4.PNG

    please suggest what else i can do ?

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    Hi,

    There is a setting on Accounts receivable parameters form, where we can select the default order type for the sales order. Is there any reason, you don't want to use this setup.

    0640.AIF.jpg

    (Code is present in \Classes\AxdSalesOrder\salesType as pointed by you).

    If not, we have to customize the salesType method as per your requirement.

    Thanks,

    Chaitanya

  • Rohin Profile Picture
    Rohin 4,624 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    @Ajit: I saw parmsalesType() , i changed the default parameter value to Sales (before it was Journal) but didn't work. It creates salesOrder of journal Type for customer requested

    first time SalesOrder.

    @Chaitanya : Well, shared above code is written in PrepareForSalesTable() only. but didn't work. Yes this method is called by prepareForSave() method. Even i wrote below code in PrepareForSave() under classNum(AXSalesTable):

    axSalesTable.parmSalesType(SalesType::Sales)

    but no works. I don't understand where AX gets default journal type.please suggest

  • Verified answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    Hi,

    Please include your code in the prepareForSave method of AxdSalesOrder(as this will be called just before record creation) under the case with classNum(AxSalesTable) like _axSalesTable.parmSalesType(SalesType::Sales)

    To be precise, include your code in method prepareSalesTable(as its holds default logic for salesType) of class AxdSalesOrder(it is called from PrepareForSave) based on your condition/business requirement.

    Hope this helps you.

    Thanks,

    Chaitanya Golla  

  • Suggested answer
    Ajit Profile Picture
    Ajit 8,755 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    If that is not working, you can check 'ParmSalesType' method of 'AxSalesTable' class and make changes there.

  • Rohin Profile Picture
    Rohin 4,624 on at
    RE: AIF Inbound Service creates Sales Order of Journal SalesType

    well, I usually do search before creating new thread .

    Anyways , solution mentioned in above thread didn't work. I came around another solution by changing below code instead of comment it:

     if (!_axSalesTable.salesTable())

        {

          createRecord = true;

            _axSalesTable.parmSalesType(this.salesType());  // salesType method changes is shown below

            select firstonly RecId from localSalesTable

                where localSalesTable.CustAccount       == _axSalesTable.parmCustAccount()

                   && localSalesTable.PurchOrderFormNum == _axSalesTable.parmPurchOrderFormNum()

                   && localSalesTable.SalesId           != _axSalesTable.parmSalesId();

            if (localSalesTable.RecId)

            {

                _axSalesTable.parmSalesType(SalesType::Sales);

            }

            if (_axSalesTable.parmInvoiceAccount())

            {

                custTable      = CustTable::find(_axSalesTable.parmCustAccount());

                invoiceAccount = custTable.InvoiceAccount ? custTable.InvoiceAccount : custTable.AccountNum;

                if (invoiceAccount != _axSalesTable.parmInvoiceAccount())

                {

                    _axSalesTable.parmSalesType(SalesType::Sales);

                }

            }

    protected SalesType salesType()

    {

        switch (AxdDocumentParameters::find().SalesType)

        {

            case AxdSalesType::Journal :

                return SalesType::Journal;

            case AxdSalesType::Sales :

                return SalesType::Sales;

        }

       // return SalesType::Journal;  // comment this line

        return SalesType::Sales;

    }

    But this is only creates salesOrder of salesOrder type if customer has requested salesOrder before. If customer doesn't have salesorder requested before , it create salesOrder of JournalType.

    any suggestion please?

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans