Need to fetch multi enum value for every work item - enums

In my report i need to print yes or no values by fetching values from multi select enum custom field for every work item ,if work item's custom field has value then need to print as yes into the column ,else print as No, similarly need to check for each for each work item .
I am using the below code snippet , but its not working , can anyone please help me to resolve this As soon as possible .
#foreach($ref in $refList)
#set($refWi = $transaction.workItems().getBy().oldApiObject($ref))
#set($arr=[$refWi.fields().get("Values")])
#foreach($item in $arr)
#if($item == "Tablets")
#set($isTablet = "YES")
#else
#set($isTablet = "NO")
#end
#end
#end
Printing the YES/No value .

Related

Hide an element conditionally by its value

I have a kendo grid containing following columns.
1.Name
2.Age
3.Type{values:public,private}
I need to hide a column in specific row. In my problem, i want to hide age cell if Type value is private.
using if else format
columns.Template(#<text></text>)
.ClientTemplate("#if (field == value) {#"
+ "<a></a>"
+ "#}else {#"
+"<input name='chkSubscribed' class='subscribedClass'type='type': '' #/>"
+ "#} #").Width(130).Title("title");
You can't hide the cell but you can hide the age depending of the other columns. See https://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-to-apply-conditional-logic-to-client-column-templates on how to apply conditional logic to columns?

APEX Office print

I am currently working with the Apex Office Print it would be nice if you could help me with two points.
I am creating a template with a lot of fields, and around 50% of
these fields are optional, so they are often only (null) in my
database. Can I do something so that the fields with no value are not
shown?
My second question would be the work with the print function and
checkboxes. How do I integrate the item APEX_APPLICATION.G_F01 so
that I only print the content of a selected checkbox ? It is not
really working in the PL/SQL section.
I am creating a template with a lot of fields, and around 50% of these fields are optional, so they are often only (null) in my database. Can I do something so that the fields with no value are not shown?
The {tag} will just be removed when it's empty. In case you want to make some blocks disappear you can wrap that in a condition,
for example:
{#tags=null} {product_name}: {product_description} {/tags=null} {#tags!=null} {product_name}: {tags} {/tags!=null}
or if you have a value:
{#checked=="Yes"}☒Yes ☐No{/checked=="Yes"}{#checked!="Yes"} ☐Yes ☒No {/checked!="Yes"}
My second question would be the work with the print function and checkboxes. How do I integrate the item APEX_APPLICATION.G_F01 so that I only print the content of a selected checkbox ? It is not really working in the PL/SQL section.
Are you running the AOP Process type plugin or the Dynamic Action plugin?
For example we use it for ourself when selecting invoices and printing them.
We have a checkbox in an IR:
apex_item.checkbox2(
p_idx => 1,
p_value => id,
p_attributes => 'class="invoice_id"',
p_checked_values => :P39_INVOICE_ID_LIST,
p_checked_values_delimiter => ',') as chk,
And then we have a Dynamic Action on change that sets an hidden item (P39_INVOICE_ID_LIST) on the page:
var
//Checkbox that was changed
$checkBox = $(this.triggeringElement),
//DOM object for APEX Item that holds list.
apexItemIDList = apex.item(this.affectedElements.get(0)),
//Convert comma list into an array or blank array
//Note: Not sure about the "?" syntax see: http://www.talkapex.com/2009/07/javascript-if-else.html
ids = apexItemIDList.getValue().length === 0 ? [] : apexItemIDList.getValue().split(','),
//Index of current ID. If it's not in array, value will be -1
idIndex = ids.indexOf($checkBox.val())
;
//If box is checked and it doesn't already exist in list
if ($checkBox.is(':checked') && idIndex < 0) {
ids.push($checkBox.val());
}
//If box is unchecked and it exists in list
else if (!$checkBox.is(':checked') && idIndex >= 0){
ids.splice(idIndex, 1);
}
//Convert array back to comma delimited list
apexItemIDList.setValue(ids.join(','));
In our query in the AOP DA we have:
where i.id in (select regexp_substr(:P39_INVOICE_ID_LIST,'[^,]+', 1, level) invoice_id
from dual
connect by regexp_substr(:P39_INVOICE_ID_LIST, '[^,]+', 1, level) is not null)
and we make sure the P39_INVOICE_ID_LIST is set in session state by specifying the Affected Elements of the AOP plugin call.
If you setup an example of what you want to do on apex.oracle.com I'm happy to build you the example there. In AOP 4.0 we will also include an example with checkboxes.
Hope that helps,
Dimitri

Clicking on specific row in a WebTable using UFT/QTP

I am having hard time clicking specific row in a Web Table. My code finding proper row, but when I use Child Item method it complains that Object is not found. Here is my code:
Desc = "Record to click"
If Browser("B").Page("P").WebTable("W").exist(10) Then
totalRows = Browser("B").Page("P").WebTable("W").RowCount()
For RowNum = 1 To totalRows
If aDesc = Browser("B").Page("P").WebTable("W").GetCellData(RowNum,2) Then
Browser("B").Page("P").WebTable("W").ChildItem(RowNum,2,"WebElement",0).click
End If
Next
End If
I spied on the value in the row it is Web Element, I tried to use Link- didn't work. Also I tried to Child Item(aDesc,2,"WebElement",0)- didn't work either. I used 0 for the index because there is only one element in the row - simple text. I keep getting this error in many other tests. On rare occasion this approach works in some tests, but most of the time it complains for absence of object.
Thank you very much for your help!
It happened with me as well. When I researched, I found in some of the old HP blogs that ChildItem method does not works correctly with WEBElement, but that was for QTP 9.0, and I was using 12.02.Anyhow, I can't figure out why its happening, and ended up using the following -
Set oExcptnDetail = Description.Create
oExcptnDetail("micclass").value = "WebElement"
oExcptnDetail("html tag").value = "TD"
Set chobj=Browser("").Page("").WebTable("Code").ChildObjects(oExcptnDetail)
chobj(0).Click
On a side note, in order to check a webelement/link exist in a certain row and column, use the following.
Browser("B").Page("P").WebTable("W").ChildItemCount(2,2,"WebElement")
Getcell data will return you anything that is in the desired row and column irrespective of what it is (link,webelement etc) and hence your assumption of if loop will go wrong.
Try this:
Browser("B").Page("P").WebTable("W").object.rows(rownum-1).cells(colnum-1).Click
I was trying to click the first link in my table and this code clicked the item
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"
Set rc = Browser("B").Page("A").WebTable("html id:=gridTable").ChildObjects(oDesc)
rc(0).Click
'num = rc.Count() 'get the number of link in a page
'For i=0 to num-1
'ref = rc(0).GetROProperty("href") 'get the “href”propety of the i th link
'MsgBox ref
'Next
or
Browser("B").Page("A").WebTable("html id:=gridTable").ChildItem(2,8,"Link",0).click
successfully clicks the link I needed

How can I make automatic generated column in Adempiere ?

I have two columns called Quantity and Issued Quantity. I want that when I put value in Quantity column, for instance 3, the Issued Quantity will automatically generate 3. Also I want it to happen the other way around.
The example is on Purchase Order window, PO Line tab. in Quantity section. When I put 4 in Quantity field, the PO Quantity field automatically generate 4.
I try to imitate the column and field but it doesn't work.
This is accomplished in Adempiere by a Callout which is configured in what Adempiere calls the Application Dictionary
From the example you gave; updating the qty on the Purchase Order.
If you login to Adempiere using the System user, you can view and modify the Application Dictionary.
From the main menu select Application Dictionary->Table & Column.
In the Search box that opens enter C_OrderLine as the DB Table name.
Now Column tab and scroll down the list to locate the QtyEntered column. Switch to the Form view and near the end you will see were you can enter the field Callout.
You should see that the C_OrderLine.QtyEntered field already has a value "org.compiere.model.CalloutOrder.qty; org.compiere.model.CalloutOrder.amt" which indicates it should run the method qty in the class org.compiere.model.CalloutOrder followed by the method amt in the org.compiere.model.CalloutOrder class.
If you open those classes you can see how easily you can evaluate and modify values. Breaking some of of it down for you... if you open the CalloutOrder.java class you cab scroll down until you find the qty method.
public String qty (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
You need use the signature as above for any new callout method you create. Follow that approach and Adempiere will look after passing the correct values for you
if (isCalloutActive() || value == null)
return "";
It's good practice to start the method with the above ensure you do not open a Callout from within a Callout - which would break the Adempiere rules.
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
Is an example of how you could extract values from the existing window... the syntax would remain the same regardless of Column/Field the you just need to enter the "M_Product_ID" which is the Field name you wish to extract to use.
Now this Callout is called by more than one Column/Field so it is littered with a big if...then...else to executed the logic needed for the relevant field. It's not pretty, but this is aimed at business developers who will concentrate more on business logic than coding principals.
The code you are interested in is
else if (mField.getColumnName().equals("QtyEntered"))
{
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, "C_UOM_ID");
QtyEntered = (BigDecimal)value;
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0)
{
log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
+ "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
QtyEntered = QtyEntered1;
mTab.setValue("QtyEntered", QtyEntered);
}
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (QtyOrdered == null)
QtyOrdered = QtyEntered;
boolean conversion = QtyEntered.compareTo(QtyOrdered) != 0;
log.fine("UOM=" + C_UOM_To_ID
+ ", QtyEntered=" + QtyEntered
+ " -> " + conversion
+ " QtyOrdered=" + QtyOrdered);
Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N");
mTab.setValue("QtyOrdered", QtyOrdered);
}
The code
mTab.setValue("QtyOrdered", QtyOrdered);
Is where it sets the value of the other quantity field Qty Ordered.
Also, the call must not be Java. It is possible to link any [JSR223 script][3]. I never actually tried this approach myself, but it is even possible to implement Callouts using the Drools Rules Engine!

Display "No Data" message when table is empty in BIRT Report

I want to hide a table and to report that "No Data" message is present if the query returns no data.
In computed columns i have added the columns which counts the number of rows present(i.e.TableCheck).
and i have created label just below the table with the message "No Data". In script onCreate i have added the below code.
if( countOfRows == 0 ){
this.getStyle().fontStyle = "italic";
this.getStyle().fontSize = "large";
}else{
this.text = "";
}
countOfRows = 0 is initialize in script.
In table visibilty propery, checked the Hide Element and added the below code in expression.
if (row["TableCheck"] == null){
true
}
else{
false
}
Problem: When dataSet is empty "No Data" Message is displaying.But when data set is not empty, then error message is not hiding.
Please let me know how to fix this.
Thanks in Advance.
Do it this way:
First add visual elements to display it when data set doesn't return any row.
Then define global variable in Initialize script of report root.
For example
rowsReturned = 0;
On your table that you'll evaluate data set to see is there rows returned on Visibility tab set next:
On elements you want to display whene there is no returned data set this on Visibility tab
If you want to hide the table when no data returned, you can write this in its Visibility property:
row.__rownum < 0
and in Visibility property of your "No Data" message you use the opposite check:
row.__rownum >= 0
Note that both components must be bound to the data set you want to check. In the case of the message component you can achieve this putting it in a header or footer row.
Alternative solution without using global variables (though functionally not quite the same, because the layout will always contain a table):
Add a binding numRows for the COUNT aggregate with the expression 1 to the table.
Set as visibility expression on the table header row:
!row["numRows"]
Add a new footer row to the table; for this footer row set the visibility expression
row["numRows"]
Merge the cells in this footer row, then place a label "No data found" into the table cell.

Resources