SBX - Search With Button

SBX - Forum Post Title

IIF Condition

Microsoft Dynamics NAV Forum

jsshivalik asked a question on 12 Aug 2017 12:50 PM
My Badges

Question Status

Verified

Hi

  I want if Balance is < 0 then it should show Balance Amount + 'Dr'. If > 0 then Balance Amount + 'Cr' in report textfield

Thanks

Reply
Amol Salvi responded on 12 Aug 2017 1:21 PM
My Badges
Verified Answer

You can write this code on onaftergetrecord trigger

If balance >0 then

 Balanceamount :=format (balance)+'dr'

Else

 Balanceamount:=format(balance)+'cr'

Define balanceamount aa variable with datatype text

Reply
Tina Menezes responded on 13 Aug 2017 11:00 AM
My Badges
Verified Answer

Hi,

You can define a variable 'Result' with datatype 'Text' in C/AL globals. Now in OnAfterGetRecord trigger you can write the following code:

IF Balance <0 THEN

Result:=FORMAT(Balance)+' Dr'

ELSE

Result:=FORMAT(Balance)+' Cr';

Use this text variable 'Result' in your report textfield.

Reply
Mahesh responded on 13 Aug 2017 9:56 PM
My Badges

Hi,

You may use the methods mentioned by Amol and Tina

Reply
Yogesh Kulkarni responded on 14 Aug 2017 1:10 AM
My Badges
Suggested Answer

Yes, you may use the methods by Amol sir and Tina.

Or else you can directly provide the Expression of the Textbox as:

iif(Balance < 0,CStr(Balance)+"Dr",CStr(Balance)+"Cr")

 

-Yogesh Kulkarni
Please verify, if you find answer helpful.

Reply
Amol Salvi responded on 12 Aug 2017 1:21 PM
My Badges
Verified Answer

You can write this code on onaftergetrecord trigger

If balance >0 then

 Balanceamount :=format (balance)+'dr'

Else

 Balanceamount:=format(balance)+'cr'

Define balanceamount aa variable with datatype text

Reply
Tina Menezes responded on 13 Aug 2017 11:00 AM
My Badges
Verified Answer

Hi,

You can define a variable 'Result' with datatype 'Text' in C/AL globals. Now in OnAfterGetRecord trigger you can write the following code:

IF Balance <0 THEN

Result:=FORMAT(Balance)+' Dr'

ELSE

Result:=FORMAT(Balance)+' Cr';

Use this text variable 'Result' in your report textfield.

Reply
Yogesh Kulkarni responded on 14 Aug 2017 1:10 AM
My Badges
Suggested Answer

Yes, you may use the methods by Amol sir and Tina.

Or else you can directly provide the Expression of the Textbox as:

iif(Balance < 0,CStr(Balance)+"Dr",CStr(Balance)+"Cr")

 

-Yogesh Kulkarni
Please verify, if you find answer helpful.

Reply

SBX - Two Col Forum

SBX - Migrated JS