I’ve had a very interesting problem. When I click on a link on Page 1 in Component A, it should take me to Page 2 in Component B after providing values in the Search page, and enter values on Level 0 of Page 2 and simulate pressing of a Push Button on the same page.
Okay, here goes. 🙂
On Page 1’s hyperlink’s FieldChange, write the following code (illustrative purposes only – replace with your menu and other object names)
Local Record &rec; &rec = CreateRecord(Record.PERS_SRCH_GBL); /* Search record of the target component */ &rec.EMPLID.Value = "KU0002"; /* assign value to search key field (this example assumes EMPLID is the only search key on the target component) */ &URLString = GenerateComponentPortalURL(%Portal, %Node, MenuName."MANAGE_PAYROLL_PROCESS_(GBL)", %Market, Component."GP_SS_PSLP_ADMINVW", Page."GP_SS_PSLP_ADMINVW", "U", &rec); &content1 = "&FROM_DATE=06/29/2014&TO_DATE=09/29/2014"; ViewURL(&URLString | &content1, True);
In the above code, PERS_SRCH_GBL is the Search record of GP_SS_PSLP_ADMINVW, which has EMPLID as key. But, once I get into the page(GP_SS_PSLP_ADMINVW), whatever value I have from Page 1 should be populated on the FROM_DATE and TO_DATE fields on the GP_SS_PSLP_ADMINVW page. Now, if you have additional fields on your page that should have values populated, you can always modify variable &content1’s text.
Make sure you remember to put an ampersand (&) after each parameter.
&content1 = "&FROM_DATE=06/29/2014&TO_DATE=09/29/2014";
Now that the first part is done, lets proceed to the next step.
Open GP_SS_PSLP_ADMINVW.PageActivate PeopleCode
Local string &from_date = %Request.GetParameter("FROM_DATE"); Local string &to_date = %Request.GetParameter("TO_DATE"); Local string &emplid = %Request.GetParameter("EMPLID"); If All(&from_date) Then DERIVED_PSLP_GP.FROM_DATE.Value = &from_date; End-If;
This PeopleCode gets the values that we had passed to the URL and uses it in the Page. And to simulate the Push Button, all I had to do was to look for the code that gets triggered when clicking on the Page button. And that fortunately happened to be a single function. 🙂
All I had to do was to call the function within the above if-loop.
And, voilà! I couldn’t find better alternatives. If you find one, please add them in the comments section. I’ll have the posted updated with your code, with due credit of course. 🙂
Until then, have fun!! 🙂