form help [message #635251] |
Wed, 25 March 2015 09:52 |
|
swetaranjan
Messages: 11 Registered: March 2015 Location: kolkata
|
Junior Member |
|
|
Can any one suggest a logic for the below scenario
When user clicks on the checkboxes all the checkboxes should be checked except one . For the last unchecked one ,it will display a error when the user tries to check it.
I have taken count from the table and if the count is 1 it will show the message . also i have used this when checkbox change trigger. But when the user tried to uncheck the checked one same error comes . I dont want the error to come , when the user unchecks the checked one. Please suggest
|
|
|
|
|
|
|
Re: form help [message #635353 is a reply to message #635332] |
Fri, 27 March 2015 08:43 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
swetaranjan wrote on Fri, 27 March 2015 02:57
AND (t1.checkbox <> 'Y' or t1.checkbox <> is null);
That is invalid syntax so there is no way this could be your code.
|
|
|
Re: form help [message #635355 is a reply to message #635333] |
Fri, 27 March 2015 09:52 |
|
CraigB
Messages: 386 Registered: August 2014 Location: Utah, USA
|
Senior Member |
|
|
Committing each checkbox's value to the database is not a good idea; it creates too much network traffic and can make your form slow. Things like; is a checkbox checked, how many checkboxes are checked, etc., are all calculations that can occur in your form without a trip to the database. Also, try to avoid looping through a data block to determine a condition. This too will cause your form to appear slow. A better approach would be to use a calculated field in your data block and summarize the CHECKBOX item. This gives you a quick way of checking to see if any checkboxes are checked without having to loop through your block or have to make a trip to the database. In order to use a calculated field, you have to set the block property Query All Records = YES and then add a non-table item to your block. You can call this item anything you want, but I recommend something that suggests its purpose; for example: SUM_CHECKBOXES. Once you have the SUM_CHECKBOXES item added to your block, set the following properties:
1. Data Type = Number
2. Calculation Mode = Summary
3. Summary Function = Sum
4. Summarized Block = <Your Block Name here>
5. Summarized Item = <Name of your Checkbox Item here>
6. Number of Items Displayed = 1 (only if you are going to show this item on your canvas).
- - I recommend you display the item during testing just so you can see how the value changes as you check and uncheck checkboxes.
7. Database Item = No
Quote:When user clicks on the checkboxes all the checkboxes should be checked except one . For the last unchecked one ,it will display a error when the user tries to check it.
Based on your requirement, you will need to add two additional Non-Table non-displayed items to your data block. The first is the REC_NUM and the second is a second Calculated Item that summarizes the number of records (REC_NUM) in your block so you can perform a comparison against the number of records in your When-Checkbox-Checked (WCC) trigger. First, add the REC_NUM non-table item to your block with these properties:
1. Data Type = Number
2. Database Item = No
3. Visible = No (Show it during development just so you can see how it gets changed)
Now add your second Calculated Item called SUM_RECS with these properties:
1. Data Type = Number
2. Calculation Mode = Summary
3. Summary Function = Sum
4. Summarized Block = <Your Block Name here>
5. Summarized Item = REC_NUM
6. Number of Items Displayed = 1 (Assuming your item is in a multi-record block, you don't want more than one showing)
7. Database Item = No
8. Visible = No (Show it during development just so you can see how it changes).
Now add the following triggers:
1. When-Create-Record
:YOUR_BLOCK.rec_num := 1;
2. Post-Query
IF (:YOUR_BLOCK.REC_NUM IS NULL) THEN
:YOUR_BLOCK.REC_NUM := 1;
END IF;
3. Finally alter your When-Checkbox-Checked trigger
IF ( Checkbox_Checked('YOUR_BLOCK.YOUR_CHECKBOX_ITEM') ) THEN
IF ( :YOUR_BLOCK.SUM_CHECKBOXES = :YOUR_BLOCK.SUM_RECS ) THEN
:YOUR_BLOCK.YOUR_CHECKBOX := 0; -- This ensures the checkbox is unchecked after you display your message.
Clear_Message();
FND_Message.SET_STRING('You can't Check all items!');
FND_Message.Error;
END IF;
END IF;
This method requires you to change the value of your Checkbox from a CHAR and values Y/N to Number and value 1/0. I also recommend you set the Check Box Mapping of Other Values to "Not Allowed" and your Value when Checked = 1 and Value when Unchecked = 0.
Now, when your user tries to click the last checkbox they will immediately see your message, 'one checkbox should be there'.
Hope this helps.
Craig...
|
|
|
|
|