Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Performing DB Operations only after Form Validation

Ssb_94
Level 5
Level 5

Hello Folks,

I am trying to perform a DB operation i.e., Insert on click of Save and it should be persisted to DB only after successful validation of form fields. I understand that we can invoke Validate Form, but it actually validates entire form (all sections within a form) and we don't want it to be happen like that. Instead we are trying to do this for each section at a time.

I tried the following in Rule Editor of Save Button:

var errors = [];
panelName.validate(errors);
if(errors.length > 0){
show errorMessage; // Display only error message and no DB operation should be performed
} else {
hide errorMessage; 
fdmInsert service; // Perform DB Operation only here
}

However it seems to be not working as I expected, only validations are checked correctly, whereas DB operation is not functioning. But If I try DB operation alone without any validation check, then it is functioning fine. I don't want it to happen like that.

Another alternative I tried is writing separate rules for Validation and DB Operation, but since both rules are getting executed in tandem instead of following order, this doesn't help here.

Please provide your suggestions on how best this can be done. As usual your quick help is appreciated!!

Regards,

Sri Bhargav

Designer Form Manager
1 Accepted Solution
Mayank_Gandhi
Correct answer by
Community Advisor
Community Advisor

@Ssb_94 please verify if the validation is working correctly first. I doubt that fdm would have any issue once place in the correct block. 

View solution in original post

3 Replies
Ssb_94
Level 5
Level 5

Folks any inputs please? First of all is it possible (or) is that a bug in AEM

@Mayank_Gandhi , @smacdonald2008 , @GirishBedekar 

Regards,

Sri Bhargav

Mayank_Gandhi
Correct answer by
Community Advisor
Community Advisor

@Ssb_94 please verify if the validation is working correctly first. I doubt that fdm would have any issue once place in the correct block. 

View solution in original post

Ssb_94
Level 5
Level 5

@Mayank_Gandhi 

Thanks for the response. Confirming that there is nothing wrong with FDM service, because the same FDM service when I perform without any validation check is working fine and I can able to see Data reflecting in DB.

But when done with Validation check, I found that code seems like getting terminated at below line:

guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, null, null, this);

Anything am I missing or something I am doing wrong?