Adding multiple Screen blocks on the same page based on different conditions in COM API

By | December 26, 2012

Here is the scenario.
We were working on the mutual fund applications tracking. As you might be already familiar with, we need to collect all the necessary details of an applicant for filing application in the system. I am taking one of the scenarios out of design we had achieved.
There is a First Applicant screen.

This screen captures basic demographics and primary address. Now If I select NRI in Tax Status field we need to populate one more screen to capture overseas address details at runtime.

Here is how this can be achieved at runtime.
1. First of all you have to add two basic blocks in Container box as shown below.
//’Define container
Container = eWare.GetBlock(“Container”);
Container.DisplayButton(Button_Default) = false;
//’First applicant
FirstApplicantDetails = eWare.GetBlock(“FirstApplicantDetails”)
FirstApplicantDetails.Title = “First Applicant Details”;
FirstApplicantDetails.CheckLocks = false;
Container.AddBlock(FirstApplicantDetails);
//’Primary address
FirstApplicantAddressDetails = eWare.GetBlock(“FirstApplicantAddressDetails”)
FirstApplicantAddressDetails.Title = “Address Details of First Applicant”;
FirstApplicantAddressDetails.CheckLocks = false;
Container.AddBlock(FirstApplicantAddressDetails);
2. Now let us add a Hidden variable to the container in order to save our submission action.
HdnContainer = eWare.GetBlock(“Content”);
HdnContainer.Contents += “< input type=hidden id=HdnAction name=HdnAction value=’ ‘ >”
Container.AddBlock(HdnContainer)
3. We will set the above hidden variable in order to understand that we have to load the NRI address details screen. Hence to trap the onchange we have to write below code on onchange script of the field Tax Status of first applicant details block.
function fnOnchange()
{
//’Get tax status value
var sTaxtStatus = new String(document.EntryForm.fiap_taxstatus.value)
if(sTaxtStatus==”” || sTaxtStatus==”null” || sTaxtStatus==”undefined”) sTaxtStatus=””
//’Set the value in hidden variable and submit the form
If(sTaxtStatus==”NRI”)
{
document.EntryForm.hdnAction.value = “t”;
document.EntryForm.submit();
}
}
Now we can read the values of this hidden variable from server side on next load and write below code to add new screen to container.
var sHdnAction = new String(Request.Form(“hdnAction”))
if(sHdnAction==”t”)
{
NRIAddressDetails = eWare.GetBlock(“NRIAddressDetails”)
NRIAddressDetails.Title = “Address Details of Overseas Resident Applicant”;
NRIAddressDetails.CheckLocks = false;
}
Container.AddBlock(NRIAddressDetails);
This is how we can conditionally add screen blocks to the page to hide show the blocks as per our requirement.