Wednesday, 18 January 2023

Instr & Substr functions in RTF

The substr function allows you to extract a substring from a string. The syntax for the substr function is:

substr(string, start_position, length)

string is the source string.

start_position is the position for extraction. The first position in the string is always 1.

length is the number of characters to extract

<?xdofx:substr('128.000',5,1)?>

 output = 0



The instr function returns the location of a substring in a string. The syntax for the instr function is:

instr(string1,string2,[start_position],[nth_appearance])

string1 is the string to search.

string2 is the substring to search for in string1.

start_position is the position in string1 where the search will start. The first position in the string is 1. If the start_position is negative, the function counts back start_position number of characters from the end of string1 and then searches towards the beginning of string1.

nth appearance is the nth appearance of string2.

<?xdofx:Instr('128.000','.',1)?>

output = 4



Here is an example to use substr and instr function together 

Suppose SSR_TOT_EN_TKNGPA = '128.000'

<?xdofx:substr(SSR_TOT_EN_TKNGPA,Instr(SSR_TOT_EN_TKNGPA,'.',1) + 1,1)?>

output = 0


Saturday, 19 February 2022

Peoplecode to get Long description of Translate Field

 Local Rowset &RsStatus;

&RsStatus = CreateRowset(Record.PSXLATITEM);

&RsStatus.Flush();

&RsStatus.Fill("WHERE FIELDNAME = 'L_COORDINTR_STATUS' AND FIELDVALUE = :1 AND %EFFDTCHECK(PSXLATITEM, FILL, %CURRENTDATEIN) AND EFF_STATUS = 'A'", L_MINOR_APP_FRM.L_COORDINTR_STATUS.Value);



For &l = 1 To &RsStatus.ActiveRowCount

   

   &ValueDescr = &RsStatus(&l).PSXLATITEM.XLATLONGNAME.Value;

   

   

End-For;

Saturday, 29 January 2022

Hide/ Unhide some field on grid/ scroll area

 

If IsUserInRole("CS - Student") Then

   Local Rowset  &rs2;

   

   &rs2 = GetRowset(Scroll.L_MINOR_CRSES);

   

   For &i = 1 To &rs2.ActiveRowCount

      

      rem WinMessage("here");

      &rs2(&i).L_MINOR_APP_WRK.CRSE_GRADE_OFF.Visible = False;

      

   End-For;


End-If;


Tuesday, 11 January 2022

Variables in RTF

 

 

Initialize variable to Y where Found is the name of the variable

<?xdoxslt:set_variable($_XDOCTX, ‘Found’, ‘Y’)?>

 

Print the Variable value 

<?xdoxslt:get_variable($_XDOCTX,’Found’)?>

 

Compare two variables 

<?if:xdoxslt:get_variable($_XDOCTX,’counter’) = xdoxslt:get_variable($_XDOCTX,’tot_lines’)?>


Conditions Matched, You may proceed 

<?end if?>

 

Conditional text using ‘if’ statement

Use “if” statements to customize text in your report. As an example, for the sentence ‘The document is reviewed’, we can add the word ‘not’ depending on the value of a field named STATUS.
Sample: The document is <?if@inlines:STATUS='Overdue'?>not<?end if?> reviewed.
Result: If the STATUS is ‘Overdue’ the text will read ‘The document is not reviewed’. Otherwise, it will read ‘The document is reviewed

We can use the @inlines command to force the template to lay the text out horizontally across the page rather than down the page.

 <ROOT>

<ROW><name>Mike</name> </ROW>

<ROW><name>Max</name></ROW>

<ROW><name>Nick</name></ROW>

</ROOT>

 

<?for-each@inlines:/ROOT/ROW?><?name?> <?end for-each?>

Output : Mike  Max  Nick 

Adding @inlines makes the elements to be displayed without line break.

 ---------------------------------------------------------------------------------------------

?for-each:/ROOT/ROW?><?name?> <?end for-each?>

Output : Mike

         Max  

         Nick 



BI Publisher: Conditional Format

This example will set the row background to red and font

color to white for records where Status is equal to ‘Quote_Received’.

<?if@row:STATUS=’Quote_Received’?>

<?attribute@incontext:background-color;’Red’?>

<?attribute@incontext:color;’White’?>

 <?end if?>



ifelse 

<?xdoxslt:ifelse(condition,true,false)?>

<?xdoxslt:ifelse(A.DESCRSHORT = 'CNG', 'two', 'one')?> 

If Then Else

The following statement tests the AMOUNT element value. If the value is greater than 1000, show the word "Higher"; if it is less than 1000, show the word "Lower"; if it is equal to 1000, show "Equal":

<?xdofx:if AMOUNT > 1000 then 'Higher'

  else

if AMOUNT < 1000 then 'Lower'

   else

   'Equal'

end if?>


<?xdofx:if CB_INV_TRNSTYP='D' then <?xdoxslt:set_variable($_XDOCTX,'DB',CB_INV_AMOUNT)?>

else 

<?xdoxslt:set_variable($_XDOCTX,'DB',0.00)?>endif?>

OR

<?if:CB_INV_TRNSTYP=’D’?><?xdoxslt:set_variable($_XDOCTX,’DB’,CB_INV_AMOUNT)?><?end if?><?if:CB_INV_TRNSTYP!=’D’?><?xdoxslt:set_variable($_XDOCTX,’DB’,0.00)?><?end if?>




Tuesday, 16 November 2021

Date Format in BI Publisher

 Format Current Date 

Date: <?xdoxslt:sysdate(‘DD-MON-YYYY HH24:MI’)?>


Format Date Variable 

<?format-date:A.CLASS_ATTEND_DT;'DD-MON-YYYY'?>










Saturday, 6 November 2021

AWE Ad Hoc Approver is disappearing

 I’ve got a custom AWE process, and when I try to add an Ad Hoc reviewer , I click the + button, pick a person, and everything looks fine. But when I click the standard Save button, the Ad Hoc approver disappears. On the other hand, if I click the Approve button, the process moves forward and saves the Ad Hoc reviewer.


I got this to work. If you look at the class EOAW_CORE:ENGINE:AppInst you can see this comment.

/** Has this approval process instance been saved? The process is automatically saved upon launch (and upon approve/deny, etc.–see SaveAdHocs(), below), but may also be saved by calling the Save() method explicitly. This can be necessary when users add ad-hoc approvers while previewing the process, for instance. */

At first I tried

import EOAW_CORE:LaunchManager;

import EOAW_CORE:ApprovalManager;


Declare Function createStatusMonitor PeopleCode EOAW_MON_WRK.EOAW_FC_HANDLER FieldFormula;

Component string &c_apprAction;

Component EOAW_CORE:LaunchManager &c_aweLaunchManager;

Component EOAW_CORE:ApprovalManager &c_aweApprManager;


If (L_MINOR_APP_FRM.L_MINOR_ACTV.Value = "Y") Then

   Local Record &headerRec = GetRecord(Record.L_MINOR_APP_FRM);

   Local boolean &isApprover;

   

   Local number &resp;

   

   Evaluate &c_apprAction

   When "A"

      &c_aweApprManager.AddComments(%OperatorId, &headerRec, L_MINOR_APP_WRK.COMMENTS.Value);

      &c_aweApprManager.DoApprove(&headerRec);

      L_MINOR_APP_WRK.COMMENTS.Visible = False;

      L_MINOR_APP_FRM.L_MIN_CRDNTR_CNFRM.DisplayOnly = True;

      

      

      Break;

   When "D"

      &c_aweApprManager.AddComments(%OperatorId, &headerRec, L_MINOR_APP_WRK.COMMENTS.Value);

      &c_aweApprManager.DoDeny(&headerRec);

      L_MINOR_APP_WRK.COMMENTS.Visible = False;

      L_MINOR_APP_FRM.L_MIN_CRDNTR_CNFRM.DisplayOnly = True;

      

      Break;

      

   When "S"

      

      &c_aweApprManager.AddComments(%OperatorId, &headerRec, L_MINOR_APP_WRK.COMMENTS.Value);

      L_MINOR_APP_FRM.L_MIN_CRDNTR_CNFRM.DisplayOnly = True;

      L_MINOR_APP_WRK.COMMENTS.Visible = False;

      If &c_aweApprManager.hasAppInst Then

         

         &c_aweApprManager.the_inst.Save();

         

      End-If;

      

      Break;

      

      

      

   End-Evaluate;

   

   

   

   If &c_aweApprManager.hasAppInst Then

      &isApprover = &c_aweApprManager.hasPending;

      createStatusMonitor(&c_aweApprManager.the_inst, "D", Null, False);

      L_MINOR_APP_WRK.DENIAL_BTN.DisplayOnly = True;

      L_MINOR_APP_WRK.APPROVE_BTN.DisplayOnly = True;

      L_MINOR_APP_WRK.SAVEBTN.DisplayOnly = True;

   End-If;

End-If;