Showing posts with label Peoplecode And Javascript. Show all posts
Showing posts with label Peoplecode And Javascript. Show all posts

Thursday, August 2, 2012

Related content link in Dropdown

As shown in Image to create related content link in Dropdown we need to follow below steps.

image001

Assumption: Component is created and Related content setup is done.

Below steps need to be done to use Related content in drop down.

Step1: Adding HTML Area to page.

Place a HTML area in the page to the created component.

1

Here “N_RELATED_ACTNS” is a custom Long char field.

In General Tab provide “RELATEDACTIONS” as page field name as shown in the image

2

Step 2: Hiding the Related Action Page field and making it modified by JavaScript.

Here People ID is the Related action Field defied in Related action setup page.

image

Make this field is hidden and set the page field property as below Image.

Note: Modified by JavaScript should be enabled.

image

Step 3: Code to set Related action to HTML area.

/*****************Start - Related Actions*************************/
For &i = 1 To &rs_var.ActiveRowCount
&sActionShortLabel = &rs_var(&i).N_HR_EE_DB_WRK.N_RELATED_ACTNS.GetShortLabel("RELATED_ACTION");
&sPopUpMenuJavaScript = GetHTMLText(HTML.N_GET_POPUPMENU);
&rs_var(&i).N_HR_EE_DB_WRK.N_RELATED_ACTNS.Value = &sPopUpMenuJavaScript | GetHTMLText(HTML.N_REL_ACTIONS, String(&i - 1), "N_PEOPLE_ID_DR", "%Image(PT_BTN_ARROW)", &rs_var(&i).N_MSSACTION_EMP.N_PEOPLE_ID.Value, &rs_var(&i).N_MSSACTION_EMP.N_PEOPLE_ID.Value);

End-For;
/*****************End - Related Actions*************************/

Note:String(&i - 1)” is required if this is used in grid/scroll else this can be eliminated.

Custom HTML object Definitions used in above code:

1. N_GET_POPUPMENU  - (Object Type is HTML)

<script language="JavaScript">
function ShowPopUpMenu(sFieldName,nRow, sActionFieldName)
{
CreateContextMenu(sFieldName,nRow, 3,"", 0, 0,"","%FormName",sActionFieldName);
return ;
}
</script>
 
2. N_GET_POPUPMENU - (Object Type is HTML)

<a id="relatedActionsRow$%BIND(:1)"  class="PSHYPERLINKNOUL" href="javascript:ShowPopUpMenu('%BIND(:2)','%BIND(:1)','relatedActionsRow$%BIND(:1)');" title="%BIND(:5)" ac="1"  class="PTSESRSLTRLTDINFO">

<img border="0" src="%BIND(:3)" style="width: 12px; height: 8px; cursor: pointer; vertical-align:middle: text-bottom;" ac="1" noc="1">%BIND(:4)</a>





Friday, July 6, 2012

Error on Javascript in PeopleTools 8.52: "hAction_win0 is not defined"

Below code may not work from PeopleTools 8.52. But this will work on below version of tools release (i.e. 8.50, 8.51).
hAction_win0(document.win0,pageFldName,0,0,inlabel,false,true); 



Reason:


"hAction_win0" is no longer used in PeopleTools 8.52.


Solution:


"hAction_win0" can be replaced with "submitAction_win0" for 8.52 PeopleTools.


Sample code:

submitAction_win0(document.%FormName,pageFldName,0,0,inlabel,false,true); 

Friday, May 27, 2011

Hiding Delivered Buttons based on condition

One way to hide PeopleSoft delivered component events buttons (Save, ReturnToList, Add, UpdateDisplay…. etc.) by using JavaScript. Follow the below steps to hide the delivered buttons.

This way can be used if we have Many pages in component and we don’t want delivered buttons on some pages. Here are steps.

Step1: Place HTML area in page and assign derived and work record (Say: HIDE_WRK)and field (Say: HTMLAREA) to it.

Create HTML Definition(Say: HIDE_BT_HTML) and Add following JavaScript.

<input type="hidden" name="USERJSINJECTION" value=""/>
<script type="text/javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}

function appsDisablePTControls() {

var aPTButtons = ['#ICSave', '#ICList', '#ICNextInList', '#ICPrevInList', '#ICSendNotify', '#ICNext', '#ICSpellCheck', '#ICRefresh', '#ICAdd', '#ICUpdateAll', '#ICCorrection', '#ICUpdate'];

appsDisableTable(aPTButtons,true);
}
function appsDisableTable(aPTControls,bButtons) {

var aControls, oTableNode;

var bFound = false;

var i=0;

while (i < aPTControls.length && !bFound)

{

aControls = document.getElementsByName(aPTControls[i]);

if (aControls != null && aControls.length > 0)

{

oTableNode = aControls[aControls.length-1].parentNode.parentNode.parentNode.parentNode;

if (oTableNode != null && oTableNode.id != 'RBTBHEADER' && oTableNode.id != 'RBTBFOOTER')

{

if (bButtons)

oTableNode = oTableNode.parentNode;

oTableNode.style.display='none';

bFound = true;

}

}

i++;

}
}
addLoadEvent(function() {
%bind(:1)
});
</script>
Then assign the following code to Page Activated event:
HIDE_WRK.HTMLAREA.Value = GetHTMLText(HTML.HIDE_BT_HTML, "appsDisablePTControls()");
 
Note: Refer the post for how to use Html Area: http://pawan-mundhra.blogspot.com/2011/05/run-javascript-on-your-peoplesoft-pages.html



Friday, May 6, 2011

Run JavaScript on your PeopleSoft pages conditionally

Here, PeopleCode sets the logic that determines when the JavaScript code will run.

This is not as simple as dropping a HTML Area on your page and setting the script in PeopleCode. This is because the value in the HTML Area field remains and the JavaScript code will keep executing at subsequent page refreshes.

Steps:

Lets have a derived/work record TEST_WRK And field HTMLAREA (TEST_WRK – HTMLAREA).

1. Create a HTML definition as your javascript template. Include all the necessary user-defined javascript functions that you need. Eg Html Definition is TESTJS
<input type="hidden" name="USERJSINJECTION" value=""/>
<script type="text/javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}

function user_function1() {
window.open("","toolbar = no");
}
function user_function2() {
alert('Hello from user javascript');
}

addLoadEvent(function() {
%bind(:1)
});
</script>
 

2. At the scroll level 0 of your PS page, insert a HTML Area control. Assign this to the TEST_WRK.HTMLAREA field.


3. Again at scroll level 0 of your page, insert an editbox and assign this again to TEST_WRK.HTMLAREA. And Set the Following Field Property



a. On the Use tab, check Invisible and Modifiable by JavaScript.


b. On the General tab, set Page Field Name to USERJSINJECTION.


4. Now in PeopleCode, to execute your javascript function.


GetLevel0()(1).TEST_WRK.HTMLAREA.Value = GetHTMLText(HTML.TESTJS, "user_function1()");
 
 
Thanks to http://xtrahot.chili-mango.net/.