I have placed a search button on a datawindow, and i have already an event for searching such list...how is it possible to call an event once the button is clicked on runtime.
below is the code on my event named "ue_key"
string xcode, iseries, ycode, sql_statement, xname, i_cname, name, iseries_no, irequested_by, irequest_problem, irequesting_dept, idate_request, idate_needed
string iasset_no, idate_received, istatus
long i_row
//integer
i_cname = dw_work_order.getcolumnname()
i_row = this.getrow()
if i_row > 0 then
if key = keyF2! and i_cname = 'series_no' then
//open(w_csearch)
// Then, define select statement
sql_statement = "SELECT series_no as 'Series NO', requested_by as 'Requested By' FROM work_order_form where status = 'A' or status = 'ACTIVE';"
str_sellist args
args.trans = sqlca
args.sel_cmd = sql_statement
// Specify which column will be the return value
args.retcol = 1
// Define drop-down items. NOTE: This should correspond
// with the alias you use for the columns you retrieve
args.dropdown_items[1] = "Series NO"
args.dropdown_items[2] = "Requested By"
// Define Search Window Title
args.title = "Work Order"
// Define transaction object for the window
// This is REQUIRE for now... :)
// Open with parameter
OpenWithParm(w_sellist, args)
ycode=message.stringparm
xcode = ycode
// MessageBox('test', xcode)
if trim(xcode) <> '' then
select series_no, requested_by, request_problem, requesting_dept, date_request,date_needed, asset_no, status
into :iseries, :irequested_by, :irequest_problem, :irequesting_dept, :idate_request, :idate_needed, :iasset_no, :istatus
From work_order_form where series_no = :xcode using sqlca;
// Messagebox('test', iseries)
this.setitem(THIS.GETROW(),'series_no', iseries)
this.setitem(THIS.GETROW(),'requested_by', irequested_by)
this.setitem(THIS.GETROW(),'request_problem', irequest_problem)
this.setitem(THIS.GETROW(),'requesting_dept', irequesting_dept)
this.setitem(THIS.GETROW(),'date_request', idate_request)
this.setitem(THIS.GETROW(),'date_needed', idate_needed)
this.setitem(THIS.GETROW(),'asset_no', iasset_no)
this.setitem(THIS.GETROW(),'status', istatus)
//dw_work_order.retrieve(iseries)
end if
end if
end if
Thanks a lot!
The datawindow control has "ButtonClicking" and "ButtonClicked" events. You can use these event to identify which button was clicked (check the event arguments, specifically dwo.Name) and call the appropriate code.
You'll want to make sure that your datawindow button's action is set for "User Defined (0)".
Related
I am trying to pull the Enum chosen from a dialog and assign the label to a table's column.
For example: Dialog opens and allows you to choose from:
Surface
OutOfSpec
Other
These are 0,1,2 respectively.
The user chooses OutOfSpec (the label for this is Out Of Spec), I want to put this enum's Name, or the label, into a table. The column I'm inserting into is set to be a str.
Here's the code I've tried, without success:
SysDictEnum dictEnum = new SysDictEnum(enumNum(SDILF_ScrapReasons));
reason = dialog.addField(enumStr(SDILF_ScrapReasons),"Scrap Reason");
dialog.run();
if (!dialog.closedOk())
{
info(reason.value());
return;
}
ttsBegin;
// For now, this will strip off the order ID from the summary fields.
// No longer removing the Order ID
batchAttr = PdsBatchAttributes::find(itemId, invDim.inventBatchId, "OrderId");
orders = SDILF_BreakdownOrders::find(batchAttr.PdsBatchAttribValue, true);
if (orders)
{
orders.BoxProduced -= 1;
orders.update();
}
// Adding a batch attribute that will include the reason for scrapping
select forUpdate batchAttr;
batchAttr.PdsBatchAttribId = "ScrapReason";
//batchAttr.PdsBatchAttribValue = any2str(dictEnum.index2Value(reason.value()));
batchAttr.PdsBatchAttribValue = enum2str(reason.value());
batchAttr.InventBatchId = invDim.inventBatchId;
batchAttr.ItemId = itemId;
batchAttr.insert();
Obviously this is not the whole code, but it should be enough to give the issue that I'm trying to solve.
I'm sure there is a way to get the int value and use that to assign the label, I've just not been able to figure it out yet.
EDIT
To add some more information about what I am trying to accomplish. We make our finished goods, sometimes they are out of spec or damaged when this happens we then have to scrap that finished good. When we do this we want to keep track of why it is being scrapped, but we don't want just a bunch of random reasons. I used an enum to limit the reasons. When the operator clicks the button to scrap something they will get a dialog screen pop-up that allows them to select a reason for scrapping. The code will then, eventually, put that assigned reason on that finished items batch attributes so that we can track it later in a report and have a list of all the finished goods that were scrapped and why they were scrapped.
I'm not entirely sure of your question, but I think you're just missing one of the index2[...] calls or you're not getting the return value from your dialog correctly. Just create the below as a new job, run it, make a selection of Open Order and click ok.
I don't know the difference between index2Label and index2Name.
static void Job67(Args _args)
{
Dialog dialog = new dialog();
SysDictEnum dictEnum = new SysDictEnum(enumNum(SalesStatus));
DialogField reason;
SalesStatus salesStatusUserSelection;
str label, name, symbol;
int value;
reason = dialog.addField(enumStr(SalesStatus), "SalesStatus");
dialog.run();
if (dialog.closedOk())
{
salesStatusUserSelection = reason.value();
// Label
label = dictEnum.index2Label(salesStatusUserSelection);
// Name
name = dictEnum.index2Name(salesStatusUserSelection);
// Symbol
symbol = dictEnum.index2Symbol(salesStatusUserSelection);
// Value
value = dictEnum.index2Value(salesStatusUserSelection);
info(strFmt("Label: %1; Name: %2; Symbol: %3; Value: %4", label, name, symbol, value));
}
}
This is likely embarrassingly easy but I'm new and I've been beating my head against the wall on this for a while now. What I am attempting to do is basically a modified version of the "Hello App Maker!" If else test.
The necessary info I have the following widgets attached to the appropriate data sources:
Dropdown widget called source_name (string - list)
Label widget I've called name (string)
Text Box widget called qty_duration (number)
Label widget I've called hours (number)
I have a dropdown widget called source_name with 5 options. On selection I have the value appear in a label widget I've called name. If the option selected from the drop down widget is ever LABOUR I am trying to then have the value of a Text Box widget called qty_duration appear in a label widget I've called hours
On the source_name dropdown event - onValueChange I have the following code:
// Define variables for the input and output widgets
var nameWidget = app.pages.Apex_job_details.descendants.name;
var outputWidget = app.pages.Apex_job_details.descendants.hours;
var techhours = app.pages.Apex_job_details.descendants.qty_duration;
var nothing = 0;
// If a name is LABOUR, add the qty to the output widget Else output 0.
if (nameWidget == 'LABOUR') {
outputWidget.text = techhours;
} else {
outputWidget = nothing;
}
It's not giving me any errors, but it's also not outputting to the hours label. If I edit the code as follows just to muck with it:
// Define variables for the input and output widgets
var nameWidget = app.pages.Apex_job_details.descendants.name;
var outputWidget = app.pages.Apex_job_details.descendants.hours;
var techhours = app.pages.Apex_job_details.descendants.qty_duration;
var nothing = 0;
// If a name is LABOUR, add the qty to the output widget Else output 0.
if (nameWidget == 'LABOUR') {
outputWidget.text = techhours;
} else {
outputWidget.text = nothing;
}
I'm not sure what I'm doing wrong.
Assuming all labels and input widgets are inside a table row you will want to adjust your code as follows:
var tablerow = widget.parent;
var nameWidget = tablerow.descendants.name.text;
var outputWidget = tablerow.descendants.hours;
var techhours = tablerow.descendants.qty_duration.value;
if(nameWidget === 'LABOUR') {
outputWidget.text = techhours;
} else {
outputWidget.text = null;
}
By using widget.parent in the onValueChange event of the dropdown you will automatically reference the table row and then by using descendants you are referencing only the descendants of that table row. This will bridge the error by using an absolute reference when using table rows. If it still doesn't work let me know.
After adding logic about creating price for object in grid it's always created "one line more" which is empty.
So, if there is need to be created two lines, it will be created 3 lines and that one addition will be empty.
Is there something what I missing in code?
[Control("CommandButton")]
class AreaActionPaneNew
{
void clicked()
{
PMCParameters contractParameters = PMCParameters::find();
PMETmpRentalObjectArea groupedAreaList; // Group by area_type and cost_type
PMERentalObjectPrice priceList;
date workingDate = currWorkingDate.dateValue();
;
super();
// Get grouped area values. Values are summed up by area_type and ancost_type
groupedAreaList = PMERentalObjectAreaCl::getRentalAreaPrCostType(pmeRentalobject.RentalObjectId, userSetting.validFrom(), userSetting.validTo() , workingDate);
ttsbegin;
while select groupedAreaList
{
select forupdate firstonly priceList
where priceList.RentalObjectId == pmeRentalObject.RentalObjectId &&
priceList.RentalCostType == groupedAreaList.RentalCostTypeId &&
priceList.AreaType == groupedAreaList.Areatype && priceList.ValidFrom == pmeRentalObject.ValidFrom;
if (!priceList)
priceList.initValue();
priceList.RentalObjectId = pmeRentalObject.RentalObjectId;
priceList.RentalCostType = groupedAreaList.RentalCostTypeId;
priceList.ValidFrom = pmeRentalobject.ValidFrom;
priceList.AreaType = groupedAreaList.Areatype;
priceList.Amount = groupedAreaList.Price;
priceList.Area = groupedAreaList.AreaValue;
priceList.Quantity = groupedAreaList.RentalQty;
if (!priceList)
priceList.Period = contractParameters.ReportPeriod;
if (priceList)
priceList.update();
else
priceList.insert();
}
ttscommit;
pmeRentalObjectPrice_ds.research();
}
}
The code looks like it only updates/inserts without creating a blank line.
From your attribute, you are using a Command Button (see here), which may have an associated command, such as New, which effectively pushes Ctrl+N, and would explain why you have a blank line.
The simplest way to check is just create a regular Button and override the clicked method, then copy/paste your code and push both buttons and see if they have different behavior.
Check the Command property on the button and see if there's something there. Try commenting out the super(); call.
You should perhaps consider just a Button or a Menu Item Button with an associated object.
i have an report query having checkbox column, here when we checked some value and sumbiteed it will move on next page and in second page there is an option to go back, when i click on go back button it has to checked the value which is previously checked and show as checked.
how to work on this in apex
my report query:
SELECT DISTINCT APEX_ITEM.checkbox (1, ASSOCIATED_PARTY_ID) Select_Checkbox,
FIRST_NAME || LAST_NAME AS Associated_Party,
EMAIL AS Associated_Party_Email,
associated_party_id,
EMPLOYMENT_STATUS,
LOCATION AS Current_Location,
CITY || STATE_PROVISION AS City_State_Provision,
MANAGER
FROM ASSOCIATED_PARTIES
WHERE associated_party_id IN (SELECT associated_party_id
FROM matters_associated_parties
WHERE matter_id = :P10_MATTER_ID);
You can save the selected checkboxes (ASSOCIATED_PARTY_ID) in a Apex_collection when u go foward.
If the user goes back you can load the selected ones from the collection.
if you are go to another page and come back to old page the selection will be there. p_checked_values =>:p604_blc_id its a apex item it will store the accociated_party_id
<pre>
apex_item.checkbox2(p_idx => 1,
p_value => blc.blc_id,
p_attributes => 'class="blc_id" id="f01_'|| rownum|| '"',
p_checked_values =>:p604_blc_id,
p_checked_values_delimiter => ',')"Select All",
<input type="checkbox" onclick="$f_CheckFirstColumn(this)" id="check_all"/>
// Created by parthiban on 11-5-2016
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(','));
</pre>
I am working on Maximo Anywhere 7.5.2 (Work Execution app). I need to filter the lookup values based on some conditions within Anywhere.
Ex: Lets consider, I have textfield which can have A or B value only, If it is A from Maximo, then the lookup field should show (P,Q,R,S) and if it is B, Lookup should show (P,Q) only.
This is trickier than you think, because you'll need to write your own code to execute to filter the subsequent lookup. For an example you can look at this code in WODetailHandler.filterAssetForLookup method.
filterAssetForLookup: function(eventContext){
var additionalasset = CommonHandler._getAdditionalResource(eventContext,'additionalasset');
additionalasset._lookupFilter = null;
//save the current asset so we can reset it if the user has to revert the value
var workOrderSet = CommonHandler._getAdditionalResource(eventContext,"workOrder");
if(workOrderSet.getCurrentRecord() != null){
this.curAsset = workOrderSet.getCurrentRecord().get("asset");
this.curAssetDesc = workOrderSet.getCurrentRecord().get("assetdesc");
this.curAssetld = workOrderSet.getCurrentRecord().get("assetld");
}
var siteid = CommonHandler._getWorkorderSiteId(eventContext);
if(siteid == null){
siteid = UserManager.getInfo("defsite");
}
var filter = [];
filter.push({siteid: siteid});
additionalasset.lookupFilter = filter;
},
Then you attach this filter in the filterMethod in the app.xml.
<lookup filterClass="application.handlers.WODetailHandler" filterMethod="filterAssetForLookup" id="WorkExecution.AssetLookup" label="Select Asset" resource="additionalasset">