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)

AIF Inbound Service creates Sales Order of Journal SalesType

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Martin Dráb Profile Picture
    237,817 Most Valuable Professional on at

    Please se a search engine to find existing resources (such as this) before creating new threads.

  • Rohin Profile Picture
    4,624 on at

    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?

  • Suggested answer
    Ajit Profile Picture
    8,755 on at

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

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    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  

  • Rohin Profile Picture
    4,624 on at

    @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

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    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
    4,624 on at

    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 ?

  • Verified answer
    Ajit Profile Picture
    8,755 on at

    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
    4,624 on at

    its working now ..thanks to all

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

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

    Thanks,

    Chaitanya Golla

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans