Hi everyone,
I have one case about dynamic action.
Now I have two column named A and B. Column, A is display only which I create dynamic action on A (I don't know how to choose action suitable for my action) to change B.
My actions is when A is not null then B = 1 else B= 0;
Thank you for your time and in advance.
Vinish Kapoor
I think you do not need to create the dynamic action on the A column as it is display-only. You can manage it by specifying the default value for column B. Below are the steps:
For column B, select Default value as SQL query and specify the following SQL query:
Now when the interactive grid loads, the B column will have the value accordingly.
Vinish Kapoor
Oh, this will work for only new rows. For existing rows, you can change the IG source to SQL query and then use this expression in that query.
Huy Nguyen
Thank you for your good idea.
Huy Nguyen
Hi Vinish, I use default for that column B by select query:
<
select case when :B is not null then 0
else 1
end
from dual; />
But when I create a new row, with :B null or not null, it still have value equal 1. Thank you.
Vinish Kapoor
As you mentioned, that your A column is read-only so it means on creating a new record the B column value should be 0 because column A will be null.
To do this, create a dynamic action on your IG and select the event Row Initialization [IG] and create a True action as following:
This should do the job. Please let me know if still any issues.
Huy Nguyen
Thank for your time. But it is my fault. Column A is display only, but it is column from I select from another table). It has value or not, belongs to another table. So, when A is not null B then 0 else 1. Sorry for my description, it is not clear.
Vinish Kapoor
Ok no problem. You can change the set value dynamic action as follows.
Create a dynamic action on your IG on event Row Initialization and create a True action as below:
Try it and let me know.
Huy Nguyen
I try this, but column B still has value of 1. But I forgot to remove default select query of B. When I remove default, column B has no value or null.
Vinish Kapoor
Because you are referring to another table for column A, then you should use Set Value type as SQL query and use the same condition you used for the IG and return a value for column B.
Huy Nguyen
Yeah, I have a got idea with you. But When I try, it does not return value. It my Sql statement for true action of Set value for event change column C
select case when lead_id is not null then 0
else 1
end from (
select u.lead_id
from dierp.users_lead u
where u.id = :C);
Item submit is C, column affect is B. You have a better idea about that? Maybe, I try create a trigger when after insert that table.
Huy Nguyen
I find out a way to solve that problem by creation trigger for that table. Thank you every one, especially Vinish Kapoor