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?