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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

If else syntax inquiry

(0) ShareShare
ReportReport
Posted on by 1,295

Hi,

I just want to ask. how to validate if the parameters has data or empty? I tried using If else statement but it doesn't pass through the code. please see the code below. 

CustAccount and CostCenter are the parameters  where I am passing the data. I just want to clarify if my code is correct if there is no data in cost center it doesn't go through....

while select ledgerJournalTrans where
LedgerJournaltrans.RecId == custvendpdcregister.LedgerJournalTrans
{
CashCollectionTmp.PDCCollectionEWT += ledgerJournalTrans.AmountCurCredit;
}

}
if(!custAccount)
{
while select custtrans where
custtrans.transdate >= fromdate &&
custtrans.transdate <= todate &&
custtrans.transtype == ledgertranstype::payment &&
custtrans.paymmode != "cwt"
//&&
//(((custtrans.accountnum == custaccount ||
//custtrans.accountnum == "")||
//(custtrans.accountnum != custaccount ||
//custtrans.accountnum !="")))
{

if(!costcenter)
{
while select subledgervouchergeneraljournalentry where
subledgervouchergeneraljournalentry.voucher == custtrans.voucher
join generaljournalentry where
generaljournalentry.recid == subledgervouchergeneraljournalentry.generaljournalentry
{
while select generaljournalaccountentry where
generaljournalaccountentry.generaljournalentry == generaljournalentry.recid &&
generaljournalaccountentry.iscredit == noyes::yes &&
generaljournalaccountentry.postingtype == ledgerpostingtype::custbalance
{
if(custtrans.paymmode != 'cwt')
{
cashcollectiontmp.ledgeraccount = substr(generaljournalaccountentry.ledgeraccount,13,3);
cashcollectiontmp.accountnum = costcenter;
cashcollectiontmp.customername = "1";//custtable::find(custtrans.accountnum).name(); //customer name
cashcollectiontmp.paymreference = custtrans.paymreference; //paym reference
cashcollectiontmp.transdate = custtrans.transdate; //collection date
cashcollectiontmp.amountcur = abs(custtrans.amountcur); // collected amount
cashcollectiontmp.companybankaccountid = custtrans.companybankaccountid; //number 17: bank issuing code (b20)
cashcollectiontmp.docnum = custtrans.documentnum; //number 15: document num
cashcollectiontmp.companybankaccountid1 = custtrans.companybankaccountid; //issuing bank
cashcollectiontmp.netamount = abs(custtrans.amountcur);
cashcollectiontmp.checkdate = custtrans.transdate;

cashcollectiontmp.insert();

}
}
}
}


else
{
while select subledgervouchergeneraljournalentry where
subledgervouchergeneraljournalentry.voucher == custtrans.voucher
join generaljournalentry where
generaljournalentry.recid == subledgervouchergeneraljournalentry.generaljournalentry
{
while select generalJournalAccountEntry where
generalJournalAccountEntry.LedgerAccount like '*' + costCenter &&
generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId &&
generalJournalAccountEntry.IsCredit == NoYes::Yes &&
generalJournalAccountEntry.PostingType == LedgerPostingType::CustBalance
{
if(custtrans.PaymMode != 'cwt')
{
CashCollectionTmp.LedgerAccount = subStr(generalJournalAccountEntry.LedgerAccount,13,3);
CashCollectionTmp.AccountNum = costCenter;
CashCollectionTmp.CustomerName = "2";//CustTable::find(custtrans.AccountNum).name(); //Customer Name
CashCollectionTmp.PaymReference = custtrans.PaymReference; //Paym Reference
CashCollectionTmp.TransDate = custtrans.TransDate; //Collection Date
CashCollectionTmp.AmountCur = abs(custtrans.AmountCur); // Collected Amount
CashCollectionTmp.CompanyBankAccountId = custtrans.CompanyBankAccountId; //Number 17: Bank Issuing Code (B20)
CashCollectionTmp.DocNum = custtrans.DocumentNum; //Number 15: Document Num
CashCollectionTmp.CompanyBankAccountId1 = custtrans.CompanyBankAccountId; //Issuing Bank
cashcollectiontmp.NetAmount = abs(custtrans.AmountCur);
CashCollectionTmp.CheckDate = custtrans.TransDate;
CashCollectionTmp.insert();
}
}
}

}
}
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    SII1MNL Profile Picture
    1,295 on at

    I have found the answer to my question. Thank you.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dekion Profile Picture

dekion 4

#2
Virginia99 Profile Picture

Virginia99 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans