Close popover
David Goins (DavidG9168)

DavidG9168 Member since 2018 4 posts
Posted: September 26, 2018
Last activity: October 3, 2018

How to programmatically trigger the click on a link in Pega

Hello all I am trying to use jQuery in order to programmatically click on a dropdown on one of the pega pages. However, it does not seem to do anything.

I can not seem to do the following (click the Add button > click Attach File(s):

The HTML for this looks like this:

<td class="dataValueWrite" style="width:162px;">
      <script src="webwb/pega_yui_menu_154956905.js!pega_yui_button_13563920726.js!!.js" type="text/javascript"></script>
   <div class="SplitButton">
      <nobr><span id="attachButtonContainer" style="display: inline; visibility: visible;"></span></nobr>
      <table border="0" cellpadding="0" cellspacing="0" class="buttonMainTable">
               <td class="buttonTdLeft" onclick="if(typeof(pega) !='undefined' &amp;&amp; pega.u.d) pega.u.d.fireButtonClick(this.parentNode);">
                  <div class="buttonLeftContent">
                     <div class="buttonLeftContentInner">
               <td class="buttonTdMiddle" nowrap><span class="yui-button yui-menu-button" id="mb1"><span class="first-child"><button tabindex="0" type="button"><span class="yui-button yui-menu-button" id="mb1">Add</span></button></span></span></td>
               <td class="buttonTdRight" onclick="if(typeof(pega) !='undefined' &amp;&amp; pega.u.d) pega.u.d.fireButtonClick(this.parentNode);">
                  <div class="buttonRightContent">
                     <div class="buttonRightContentInner">
      <input id="atchTyp" name="$PpyWorkPage$ppyAttachmentType" type="hidden" value="">

and the associated JS for this seems to be this:

pega.u.d.fieldValuesList.put("MENUBUTTON_DEFAULT_TITLE","Menu collapsed. Click to expand.");
pega.u.d.fieldValuesList.put("MENUBUTTON_MENU_VISIBLE_TITLE","Menu expanded. Click or press Esc to collapse.");
	var oSel = pega.util.Dom.getElementsById('mb1Sel');
	var parentTD = "";
	if(oSel != null && oSel[0] != null) {
		var aOptns = oSel[0].options;
		var iLen = aOptns.length;
		var txtValMap = new Object();
		for(var i=0; i<iLen; i++)
		var oMB1 = new pega.widget.Button("mb1", { type: "menu", 
         		                                   menu: "mb1Sel"});

		var oMenu = oMB1.getMenu();
		oMenu.clickEvent.subscribe(onMOptnClk, txtValMap, true);
		pega.util.Event.addListener(document.getElementById("HARNESS_CONTENT"), "scroll", function(){ oMenu.hide();}, oMenu, true);
	var oSel2 = pega.util.Dom.getElementsById('mb1Sel');
	if(oSel2 != null && oSel2[0] != null) {
		oSel2[0].style.display = 'block';
		oSel2[0].style.visibility = 'visible';
	var sBC = pega.util.Dom.getElementsById('attachButtonContainer');
	if (sBC != null && sBC[0] != null) {
		sBC[0].style.display = 'inline';
		sBC[0].style.visibility = 'visible';

function onMOptnClk(ev, args, txtValMap) {
	ev = args[0]; 
	var o = pega.util.Dom.getElementsById('atchTyp');
	var txt = "";

	txt = pega.util.Dom.getInnerText(pega.util.Event.getTarget(ev));
	var val = txtValMap[txt];
	if(val != null) {
		o[0].value = val;
		if(val == 'ECM'){
			pega.u.d.processAction('AttachmentForECM', '', '','','',true,ev);

		}else if (val == 'File'){
			pega.u.d.processAction('pyAttachContent', '', '','','',true,ev);
		}else {
			pega.u.d.processAction('Attachment', '', '','','',true,ev);

When trying the following, nothing seems to happen (open the Add button):


Even just trying to bypass opening the Add box and just simply click on the Attach File(s) doesnt seem to work either:


Is there a Pega API to do this? Or am i trying to get the incorrect ID for these things?

***Edited by Moderator Marissa to update platform capability tags****

Pega Platform Low-Code App Development
Moderation Team has archived post,
Close popover This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.