Updating same record twice using two Form widgets in a single screen

Updating same record twice using two Form widgets in a single screen

  

Hi!

I a have a requirement in which I am having two table records i.e TblSomeDetails
Record ASomeDetails & Record BSomeDetails

In the UI I'm having three Form in total

  • Form 1 - linked to record ASomeDetails
  • Form 2 - linked to record BSomeDetails
  • Form 3 -  linked to record ASomeDetails


In the save action, I'm calling 

  • createOrUpdate for Form1
  • createOrUpdate for Form2 and then
  • update for Form1 ( by assigning the id to record which was created when the record got created)

The challenge which I'm facing is that record ASomeDetails is having the values from Form3 only and the values which we got from Form1 are replaced by 0.


Is there any solution to this?
Thanks in advance!



Hi Aditya,

Did you try to debug this where exactly it is giving problem.


Regards

-PJ-

Pramod Jain wrote:

Hi Aditya,

Did you try to debug this where exactly it is giving problem.


Regards

-PJ-

Yes, I did.
Initially as we have three forms...
Saving the first form saves some part of the record i.e ASomeDetails
Next comes, second form which is mapped to the BSomeDetails and save that.
Moving on to the next form which is remaining details for ASomeDetails, it saves the fields mapped to it but it adds empty values in the fields which were input from the first form.



HI Aditya ,

I understand the problem now , what you need to do is in your last from as well you need to bind the updated value When you set form as a source to createorupdate the action will craeteupdate based on what you have in that form.

for example if your 3rd form have data in only two fields and rest of the fileds are empty the action update them as is in the database.


Regrads

-PJ-


Pramod Jain wrote:

HI Aditya ,

I understand the problem now , what you need to do is in your last from as well you need to bind the updated value When you set form as a source to createorupdate the action will craeteupdate based on what you have in that form.

for example if your 3rd form have data in only two fields and rest of the fileds are empty the action update them as is in the database.


Regrads

-PJ-


Can you please tell the best way to bind the updated value to Form Three?

I tried refreshing the aggregate but it refreshed only the aggregate and not values which form has.
Then I tried Ajax Refresh, then also it didn't work.

Solution

After saving your form1 you can do one thing use action GetRecordforudate() and then assign only those fields in it which you want to send through Form3 and pass this in your createupdate action as a source record.

Id=CreateorUpdateA(Form1)

GetRecordForUpdate(id)

Set values GetRecordForUpdate.name=Form3.Name like this and Finally

CreateorUpdateA(GetRecordForUpdate)

Thats it.


Regards

-PJ-



Solution

Pramod Jain wrote:

After saving your form1 you can do one thing use action GetRecordforudate() and then assign only those fields in it which you want to send through Form3 and pass this in your createupdate action as a source record.

Id=CreateorUpdateA(Form1)

GetRecordForUpdate(id)

Set values GetRecordForUpdate.name=Form3.Name like this and Finally

CreateorUpdateA(GetRecordForUpdate)

Thats it.


Regards

-PJ-



Thank you so much! This worked.
Just for clearance, do we have any better method because I had 45 fields and had to assign each of these manually.
Thanks a ton! :)


Hi Aditya.,

Yes the other way is to write an advance query and set  only those fields you want to update with id in where condition.



Regards

-PJ-