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.
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 am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?
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 created a simple workflow in CRM 2011 which checks a field value in one entity and creates a new record in a different entity. Sometimes however, the creation doesn't occur, it just seems that the condition is not met when it should be.
Consider an entity called "Car" which has a text field called "Task". This Task field will always be saved with 1 of 4 possible values: "", "Add", "Change", "Delete".
This value is used to determine how the workflow should process.
The workflow is set to fire when a different field is changed - "Driver".
The workflow is setup like this...
- Condition
- If "Task" == "Add"
- create new record
- Else if "Task" == "Change"
- create new record
- Else if "Task" == "Delete"
- create new record
- Reset "Task" to ""
NOTE: the created record is using different values depending on "Task"
I can see that the workflow is always fired when expected, and both the "Condition" and the "Reset" are processed. The problem is that sometimes (although, not so far today) no record is created - this suggests that none of the IF conditions are met. However, I have no reason to explain why. I can see that the field "Task" is always set as expected prior to the save (exact spelling/casing and all)
So, are there any known issues with CRM workflows that could explain this? Is there a more indepth way to debug these issues? (i.e. check the value of "Task" at time on "Condition" checks)
I am wondering is it possible that the "Reset" part of the workflow is somehow being processed before the condition? and there for the condition is checking a blank field.
Any help will be greatly appreciated, Thanks
Unfortunately, I have not experienced this issue again since the first time when I created the workflow.
However, some good techniques where offered in comments as to how this sort of issue could be debugged - thanks to those people!
Firstly, you can turn on Entity Auditing which will help you track down what is going wrong.
Another option would be to send an email from the workflow with the current data values for debugging, or add a final "else" clause to send emails when none of the conditions have been met (perhaps a good fail safe addition to have even when it does seem to all be working) - I like this second option as it is more "out of the box" thinking ;)
Anyway here you can find information on sending emails from within a CRM workflow
I am working on a job portal site where user can enter multiple profiles.
I am showing all profiles in a gridview. My requirement is now that
there should be a status link with his all profiles (it is in bit).
Example:
This is my gridview:
jobseekerid | Profileid | status
1 2 Active
1 3 DeActive
1 4 DeActive
....
....
From all of this only one profile can be active.
So when the user clicks on any inactive profile, it will become active and then all
remaining profile will become inactive.
The condition is that at a time only one profile can be active. (When he make his one profile active, the remaining ones will become inactive automatically.)
Now the Problem is, I am not able to make all the remaining profiles inactive when the user makes a profile active in the gridview.
How can I do this?
This is a common problem, and is usually solved by retaining the original dataset that you populated the gridview with. So, in your case, you should stored the dataset (or a list of profiles - whatever dataset you used to populate gridview) in a viewstate (given it is not too big, otherwise the page will load slow). Then, when you populate your gridview, you need to assign a profile ID to each click event, so you know which one got clicked. You then need to loop over the dataset that you saved in your viewstate, and update all of them (except the one that just got clicked) to inactive. The loop is not as cludgy as it sounds... with sql server 2005 and 2008 you have a new datatype called 'table', so you can pass all the other profileIDs in a one swoop to the DB to update them all to inactive.
Upon an update, loop through the table rows of the Gridview and change the values accordingly, if that's sufficient enough to update the record in the backend. If there is a value associated with it, you could hold that value in a hidden field and change the value in the hidden field as well.
If these changes are going to happen on the fly (i.e. you are updating the database upon a change), you could set a hidden field as a postback trigger and eval() it when you've clicked on whatever button is saving your updated record with the updated status. This would cause the RowCommand to fire, where you could loop through each record and update accordingly.