Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Referencing tableSection[n].row.textfield from a funtion as text source for button toolTip

Avatar

Level 7

I have a global variable: lossPayees

I have a function that is called by the "click" event of a button:

payeeButton.clickIncrement(this);

This funtion is intended to perform 2 tasks:

     1) change the caption on the button

     2) change the toolTip on the button

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        function clickIncrement(oButton)    {
   
         var capTxt     = "";
         var txtIndex   = 0;
         var ttTxt        = "";   

 

       if    (oButton.caption.value.text.value < lossPayees.value)    {              
             capTxt = String(1 + parseInt(oButton.caption.value.text.value));
             oButton.caption.value.text = capTxt;                              }

// so far, so good--everything works perfectly--more hoops to jump thru than you might expect--but the button caption changes/increments perfectly

// but now is where the trouble begins--I want to continue with this funtion and have it change the button's toolTip

// 3 line of code are added:

      

     if    (oButton.caption.value.text.value  < lossPayees.value)    {
              capTxt = String(1 +  parseInt(oButton.caption.value.text.value));
              oButton.caption.value.text = capTxt;

             txtIndex = parseInt(capTxt, 10) - 1;         //create an index
             ttTxt = String(txtIndex);                         //convert the index into a string
             oButton.assist.toolTip.value = ttTxt;     //feed it to the toolTip

//now this works--but it is not the goal--you can actually assign any string to the variable ttTxt and it works

//however--I want to fill the toolTip with text from a text field (using reference syntax):

        function clickIncrement(oButton)    {
   
          var capTxt     = "";
          var txtIndex   = 0;
          var ttTxt        = "";   


     if    (oButton.caption.value.text.value  < lossPayees.value)    {
              capTxt = String(1 +  parseInt(oButton.caption.value.text.value));
              oButton.caption.value.text = capTxt;

             txtIndex =  parseInt(capTxt, 10) - 1;                                                                                                                   //create an index
              ttTxt = xfa.resolveNode("Page1.SubformLP.TableLP.TableSectionLP[txtIndex]").Row1.TxtLP.rawValue;  //use the index       

          oButton.assist.toolTip.value = ttTxt;                           }                                                                                         //feed to toolTip

    else                                                        {
        oButton.caption.value.text = "0";

        oButton.assist.toolTip.value = "None";     }
                                            }

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I don't get any errors--the toolTip acts like that part of the script doesn't exist. The button shows the new caption and the tooTip also shows the new caption (which is the default, I believe),  instead of the text from the text field. Normally you'd expect an error from JavaScript saying it can't find the referenced object--but I don't get anything like that. BTW: using Designer ES2 9.0

Maybe the toolTip part of the script should be separated from the caption part (creat an additional function) and perhaps on a different event? Like I said, It works if I feed it a string--just won't work with reference syntax? I don't get it.

Any insight? Thanks in advance!

Stephen

1 Reply

Avatar

Level 7

All the code above isn't rendering on my browser--although I see it in the HTML source! What a mess. Try this:

function clickIncrement(oButton){

    var capTxt    = "";

    var txtIndex    = 0;

    var ttTxt    = "";  

if    (oButton.caption.value.text.value < lossPayees.value)    {

    capTxt = String(1 + parseInt(oButton.caption.value.text.value));

    oButton.caption.value.text = capTxt;

    txtIndex = parseInt(capTxt, 10) - 1;

    ttTxt = xfa.resolveNode("Page1.SubformLP.TableLP.TableSectionLP[txtIndex]").Row1.TxtLP.rawValue;

    oButton.assist.toolTip.value = ttTxt;            }

Else                        {

    oButton.caption.value.text = "0";

    oButton.assist.toolTip.value = "None";    }

                }