| Record Status [message #396586] |
Tue, 07 April 2009 05:01  |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
Hi,
I have one custom form that have some 3 fields.
First i am adding two records into the table which should not present in the table already.
Ex:
Code path key
--- ----- ----
cm11 no csa
cm12 no csa
When i queried for existing records which starts like cm1%
so it is fetching following two records.
Code path key
--- ----- ----
cm11 no csa
cm12 no csa
Now simply i am changing the value of cm11 as cm01....
Then it will throw one message like cm01 is already exist.
So what i am doing is again i am changing the cm01 as cm11...
Now also its throwing message cm11 is already exist..
Because cm11 also exist in the table because i saved it.
my requirement is,
if i am fetching existing records and changing their values that new values exist in the table and again i am changing back to old values though those values are also saved it should not throw that message...
Instead it will accept that value and should not update that table since CODE is not a primary key.
Checking the value present in the table n form is done by using following code and i have put that code in WHEN - VALIDATE - ITEM
SELECT COUNT(code)
INTO v_count
FROM DISPUTE_REASON_CODE_S
WHERE UPPER(code) = UPPER(:DISPUTE_REASON_CODE_S.code)
AND nvl(org_id,107) = :GLOBAL.ORG_ID_VALUE;
IF(v_count>0) then
FND_MESSAGE.SET_STRING('Reason Code already exists. Please enter a unique code');
FND_MESSAGE.SHOW;
RAISE FORM_TRIGGER_FAILURE;
END IF;
Can anyone help me on this??
Is this something deal with record status / trigger??
[Updated on: Tue, 07 April 2009 05:04] Report message to a moderator
|
|
|
|
|
|
| Re: Record Status [message #396614 is a reply to message #396602] |
Tue, 07 April 2009 06:01   |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
AND primary_key != <datablock.primary_key_item>
if is the case then my query will select all mismatched records..
So count is greater than 0...
It will throw that message whatever the value i will enter..
Is this something deal with record status???
|
|
|
|
| Re: Record Status [message #396693 is a reply to message #396586] |
Tue, 07 April 2009 14:08   |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Not record status - item_is_valid property.
Every item in a datablock has it's own item_is_valid property.
When you query a record every item has it's item_is_valid property set to TRUE automatically.
When you change an item the property is set to FALSE (record_status gets set to changed at this point as well).
For the item_is_valid to be set back to TRUE all validation on the item must be passed - validate from list and WHEN-VALIDATE-ITEM trigger.
If you have neither the item is validated automatically.
The fact that you're changing the value back to what it was before doesn't change the value of the item_is_valid property.
You can't save the record until all items are valid.
So what to do...
First off I'm not sure why my original suggestion won't work for you.
You're checking to see if the code entered has already been used in another record.
You said code is not the primary key.
So adding the restriction I suggested will just make sure that it ignores the current record when checking.
If that really doesn't work for you then consider wrapping all the code in the trigger in something like the following if statement:
IF :datablock.item != get_item_property('datablock.item', database_value) THEN
|
|
|
|
|
|