I am reading a queue and using an Action stage to "Get Item Data" from "Work Queue" business object. The purpose of my process to prepare a report of the status of the queue items. The "Get Item Data" action expects one input, which is the queue item ID. A bunch of output items are spit out such as Key, Status, Completed DateTime, Exception DateTime...etc.
I generated Data Items for all of the output of the "Get Item Data" Action stage. I then created a loop to go over all the queue records, populate the generated data items, and then use the information in the data items to captured the details for my reporting.
The issue that I am having is that when the loop goes to the next item in the queue, it does not entirely reset the data items. For example, if the first record in the queue was in completed status, the "Completed DateTime" data item is populated with that date and time. If the next record in the queue is an exception, it populates the "Exception DateTime" data item, which is good, but it doesn't override the "Complete DateTime" data item with blank. It keeps the date from the previous record.
In my process, I check for "Completed DateTime" and "Exception DateTime" in order to determine the status of the record and update my report. The solution that I thought of is to add a Calculation stage to reset the data items, but can't seem to reset a DateTime data item. It does not like the empty quotes "". Any suggestions would be greatly appreciated!
FYI, one of the output items is called "Status", but it is not populated with any information. Otherwise, this would have been very easy.
Disclaimer: This may not be the ideal solution, but it'll work!
Use the Calculation Stage at the end of the loop, but as you cannot set a DateTime object to 'empty', how about you set them to an odd date? E.g. 01-01-4000 00:00:00.
After you finish your initial loop to populate the report (I assume something similar to Excel), you create another loop over your report and replace all the odd dates to empty cells. Alternatively you write a macro to get rid of them all at once without the need to loop.
The best solution of course would be to properly populate the Status column in your queue, but this requires access to the code and permission to alter it (and time to do so).
Related
There are 3 set of records which I want to capture from an external excel sheet to follow the data driven approach. Scenario: There are 5 fields in the online screen: Grp No/Blclass/Bnk Code/Brnc Code and Acct No.
Now upon providing the grp and blclass and click on "Create", then the other 3 fields will get enabled for data input and when data input done for all fields, the clicking on submit will successfully complete the transaction input for a particular row from external excel.Then it will pick the second record from excel and do the same and so on... Now the scenario is Suppose for the second record,if the acct no is wrong, then it will show an online error and will not allow user to "Submit". At the same time, the header section(grp and billing class) will not be enabled for inputting the next data until user click the exit button because of that online error.
Now I am new in Robot Framework and tried with "Run Keyword If" but somehow it did not work.
Here are the code that I have used. If all the data in the excel are correct, then it will input the transaction one by one for all rows. But,if any wrong data found, my purpose is to skip that input and proceed for the next record as below.
Objective after clicking Submit Button:
If error found, click Exit button and input the next record - as without exit, the header fields will not be enabled for data input
Else input the next record as per loop
You can try :
Run Keyword If '<condition1>' == '<value1>'
... ELSEIF '<condition2>' == '<value2>'
... ELSE <value3>
This works for me.
I have asp.net web page which populates grid view. One of column is Status which can have (Scheduled, InProgress, Failed, OnHold, Completed) these values and another column with link in each row to edit that particular entry. Editing is only allowed for statuses Failed, OnHold, Completed not for Scheduled, InProgress on click of entry which has status Scheduled or InProgress a pop up appears saying you cannot edit.
Now, click on link and start editing data, at same time another person with same access as mine also tries to edit same data(i.e. clicks on same link) and makes Status to Scheduled and clicks submit. The data is saved in database. Before I complete editing.
Now status for that entry is Scheduled and according to requirement it cannot be edited, but I'm able to edit data and save it database.
It should not happen. How to achieve this please help.
Thanks in advance
On the function or RowUpdating Event of the grid, you should run a SQL statement checking if the status of the row currently being updated is valid for saving (per your requirements).
If it's not, then display an error that it's been updated by someone else to a status different from the one fetched by the 2nd user trying to update it.
You can make a Column in your database like "IsEdited" and whenever a record is being inserted first run a query to retrieve the value of "IsEdited" then use If-Else statement to check. If its value is True then don't run the Insert query and display error message and if its value is False then run the Insert query with data for all other columns and also a value (True) for "IsEdited" column.
If you could provide a code it would be easy to explain.
I'm having an issue binding the value of a page item to a declared variable in an anonymous PL/SQL block process.
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
Here is my code:
DECLARE
v_email_to app_user.email%type;
v_requestor VARCHAR2(15);
BEGIN
v_requestor := :P4550_REQUESTOR;
BEGIN
SELECT email INTO v_email_to
FROM app_user
WHERE userid = v_requestor;
END;
SEND_APEX_MAIL (
v_email_to,
'Your vacancy request has been rejected.'
|| chr(10)
|| 'Emailed to: ' || v_email_to
|| chr(10)
|| 'Requestor: ' || v_requestor,
'Vacancy Request Rejected'
);
END;
Does anyone have any thoughts on this?
The block works just fine if I hard code a value to v_requestor. If I try to get the value of P4550_REQUESTOR after the page has loaded, it is empty. After clicking the edit button, P4550_REQUESTOR is populated.
** **MORE DETAIL** **
P4550_REQUESTOR is a page item that resides within the Vacancy Request region which is only displayed when a conditional is met. Specifically, the conditional is an edit button associated with a table row that is created on page load. Clicking the edit button causes the details region to display, and the associated page items to be populated.
The page item values in the Vacancy Request region are populated via an Automated Row Fetch which fires After Header.
P4550_REQUESTOR has a Source Type of DB Column.
The process that fires the code above is set to fire On Submit - After Computations and Validations
If I log the value of P4550_REQUESTOR when the page loads, it shows null. If I log the value after clicking the edit button, I get the expected string value.
Process Flow Control in Oracle APEX
(This is actually useful to think about in other programming disciplines and environments.)
Problem Defined
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
The problem statement reworded in Apex terminology and presented in the form of an actual question:
There is a REPORT REGION on the page which contains the result of a direct reference to a data table/view. This report is managed by an Apex process called "Automated Fetch" and is initiated automatically by the loading of the page headers.
There is a FORM ITEM on a page which which is populated conditionally by a BUTTON ITEM selection made by the user. The BUTTON ITEM is part of the report results.
There are multiple button items. Each is associated with a value for each report record.
If the user does not select the BUTTON ITEM from the REPORT REGION, the FORM ITEM remains unassigned and contains a "null" value.
There is a defined PL/SQL block of code which is set to execute when a SUBMIT BUTTON item is pressed (also on the same page). Why does my code block (defined page process) run with a null value when it is triggered without first pressing a BUTTON ITEM from the REPORT REGION first?
Event Driven Program Design for Procedural Programmers
The answer is not obvious if you think under the paradigm of a procedural language. Without diving into a lecture on the topic, here's a visual layout of the problem space of the OP that I cooked up to illustrate how the problem can be made more obvious:
This is my Apex page design in implementation. It's generic enough to use as a template for other Apex designs. There are no flow arrows on this diagram because it's a stateful system. One thing causes another thing to happen and so on... but not always and not all at the same time.
Use Cases for Apex UI Page Designs
Try walking through a few use cases to understand how the elements broken down in the diagram operate together. Each user may take any number of click combinations and interactions, but there is a commonality:
They all enter the same initialized conditions on page load.
They all leave the page by: navigating elsewhere or through the SUBMIT button event.
Use Case #1
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #2
User enters page and reviews results displayed in the {MyPage:SQLReport} region.
User decides no additional input is necessary and then selects the {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
(a note: the state of form item {MyPage:HTML-Region:ThisItem} has not been changed from the initial null value at this point... after the submit button has been selected)
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #3
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User chooses {MyPage:SQLReport:ThisButton} from a different selection from one of the records in {MyPage:SQLReport}.
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial value stored in step (2).
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
The difference between each case should illustrate why the dependent value (ThisItem, or more specifically, page item P4550_REQUESTOR) is null in one use case vs. the other.
Building a Physical Implementation (An Apex Page)
The table I used is called STAR_EMPS. It is similar to the EMP table but has only three columns: ename, deptno and salary. Although it is not super important, this is the data set I used to populate STAR_EMPS:
I used a simple two-column table named STAR_EMPS_LOG for capturing the output of a successfully executed procedure call. You could accomplish the same with just one column, but I wanted a sequential id for tracking the order each event was recorded- for running multiple test cases. The procedure is one of several defined processes kept on this page:
contained in: {MyPage:RunCodeBlock} is below:
DECLARE
-- output from this procedure will be recorded in the star_emps_log
-- table. {MyPage:RunCodeBlock}
mycelebrity star_emps.ename%TYPE:= :P17_CELEBRITY_NAME;
mylogmessage star_emps_log.log_message%TYPE;
BEGIN
-- Conditional; changes message based on the value set for the
-- page item.
if mycelebrity is null then
mylogmessage:= 'No button was pressed on the previous page.';
else
mylogmessage:= 'The user selected: ' || mycelebrity ||
' from the report list.';
end if;
-- populate value from the page item.
INSERT INTO star_emps_log (log_message)
VALUES (mylogmessage);
commit;
END;
This is how the page layout was set up:
As in your example, I made a {MyPage:SQLReport} region with its supporting elements. The SQL Report represents a query directed at the source data table.
{MyPage:Form} has been renamed to {MyPage:HTML-Region}.
{MyPage:SQLReport} is defined by a SQL query, there is also a mock column to use as a place holder for placement of the "edit" buttons.
{MyPage:SQLReport:ThisButton} The button specifications are detailed through this:
The TWO Page processes: PROCESS and BRANCH need to be linked with the same settings referencing a BUTTON triggering Item.
User Interface Test Cases
Run through the three suggested scenarios to get started. Verify that the system is interpreting the requests correctly. This is what the page layout looks like:
The two processes on the system have a definition that wasn't mentioned in previous discussions may solve our original problem at hand:
Some Parting Thoughts
It is a good thing this turns out to be a trivial case once broken down. The diagramming method described here should scale to other Apex applications of varying complexity. There is considerable utility in stepping away from the code, locking down on terminology and trying to describe systems and processes without actual code. Please be sure to share any stories if this approach helps with your own Oracle Apex design challenges.
Onward!
The original, verbose answer seems to way overcomplicate the issue. The session state concepts manual covers this behaviour more succinctly.
Should P4550_REQUESTOR be a normal item created from a wizard, using :P4550_REQUESTOR will return a value in processes running post submit because the submit processes moves values in browser to session state.
If P4550_REQUESTOR is rendered conditionally, then it will always be null and I'm not sure what would happen if you tried to set it - probably depends how.
On a similar note, if you used &P4550_REQUESTOR. to parameterise the process, you would face the behaviour originally described (and made the code less secure)
I have one getCMSField_forpopup form for an event. I made another popup inside that to give multiple dates to that event(using has_many relation). When I give date 2 different dates/times to event "A" and then after saving event "A", I open main getCMSField_forpopup to enter details of another event "B" then I see dates/times (complextablefield) already there which were actually meant to appear in event A's detail not in event "B". I want to see those only with A not with every new event. How can I make that possible ?
Your problem is that you enter Dates for 1 Event, but then you can see this Dates on every single Event?
to me this sounds like either your Event has no ID at this time and therefore a query on Dates "WHERE EventID = x" does not work, or your Dates get saved without the ID of the Event
You could simply check your database if your Dates have the ID of an Event set.
If the ID if the Event is 0, then the issue is that you are not saving the event ID, this either means that:
you have created the Dates before saving the Event, in this case the solution is just saving the Event before you add Dates, you could also hide the Dates field when it has not been saved, see below the $this->isNew() stuff
or silverstripe fails to save the EventID, in this case you could fix it by adding a hidden field to your getCMSFields_forPopup of the Date and save the Event ID there, but its gonna be a little tricky getting this ID into the popup
if this is not the issue, then the problem is that when you create a new Event it has no ID, and therefore can not filter by ID, you can simply do this inside your getCMSFields_forPopup of the Event:
if (!$this->isNew()) {
// add your ComplexTableField for Dates here so it only
// gets added if this record has already been saved
}
But actually I would recommend using nested DataObjectManager (a DataObjectManager inside a DataObjectManager)(see tutorial on youtube: http://youtu.be/eeXOTlXFmQQ), DataObjectManager does all that work for you, so this problem should not occur.
It only displays the DataObjectManager for Dates if you have already saved the Event once, otherwise it tells the user that he needs to save it first.
And it also sets the Event ID on the Dates for you
Or, even better, you could upgrade to SilverStripe 3, where you can use GridField.
GridField works way better then DataObjectManager and looks a lot nicer.
I'm working on my first ever AIR application with flashbuilder - just so you know.
I've bound a mx:DataGrid component to a DataProvider which is a mx:HTTPService fetching an xml file with items. To keep the data up to data I'm polling the webservice on a given interval.
My problem is that I loose the currently selected item in my DataGrid when the data is updated. I've tried to save the DataGrid.selectedIndex and set when the data is updated, but I'm not sure when to do it?! The closest I've come is to restore the index when the updateComplete event of DataGrid is fired. This works, but the selection first fades away and then fades in - not updated soon enough.
So what is the best way to keep the selection? (only one selected item at a time)
And as a side question: is there a convenient way to only update the data when it has actually changed?
Thankful for any suggestions!
I'll start from the bottom, the only way to only update the data when it has changed is to pass a check on the data on the server side to see if data has changed and make that a call before the actual update. So in short, you make two calls, one to see if the data has changed, which is a server side query, and the next only if that returns true, which updates the data.
Alternatively, you can also get the update, and compare it to your current data, and only update the UI if that data is different, but I have a feeling you mean the former answer of only doing the update CALL at all, if the data has changed.
As for the other solution, after you've saved the selectedIndex, do this inside your updateComplete:
private function yourDataGridUpdateComplete(event:FlexEvent):void{
yourDataGrid.selectedIndex = yourIndex;
yourDataGrid.validateNow();
yourDataGrid.scrollToIndex(yourIndex);
}
The DG uses the UUID of the data items to determine whether the item should be still selected after a refresh. If the data items don't implement IUID they basically get random values created each time they are added to the DG.
If your data items implement the IUID and you use a consistent value (DB sequence number for example) the DG will "know" that after a refresh, the data item is the same one as before.