Function Code id in function

 10 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
I am using the TEXT_OnFocus(id, row) function, and I only need it to execute for certain fields.  I have my if (id=="text12" || id=="text13"... statement, and there are 2 fields that are not working correctly.  The fields are in the detail line section of PO20, so there is the FC column where you can A(dd), C(hange) etc.  This is one of the fields that doesn't work.  If I open the line section in DS, I cannot focus on that field.  It is in a protected state.  I looked at the source and found the id to be fc1, but when I code this in my if (id==fc1..., it still doesn't work.  All the other fields in my if statement continue to work with it coded in there. The second field that doesn't work, I can focus on in DS and it is "text17".  When I use that in my if statement, the logic will not execute at all.  It appears to cause the function to error out.  The only difference I can see between this field and those that work is in the custom properties, Has Define is checked with a URI. Does anyone know if there are fields that you can't use to do this type of function?  Thanks!
David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
Lynne, You will notice that the Text_OnFocus or Text_OnBlur also references a row number, which is how you reference the detail line fields. You need to reference both the id (your text field) and the row (which begin with zero - 0 - as the first row number).
David Williams
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
I added the row in and get different results yet. fc1 still does not work. The strange thing is that I only have "text17" (last field in detail line) and "fc1" in my if statement. All the other "text.." fields in the row work without having to reference them (since I added the row). That doesn't make sense to me but maybe because I reference the last field??? That is the one that didn't work at all before, so my problem has gotten a little better. Here's what my if looks like now: if ((id="text17",row) || (id="fc1",row)) Remaining problem is that fc1 doesn't work. Thanks for your help.
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
Upon more testing, adding the row does not work. It was disregarding the 'if' and executing on any field on the form. Someone on this forum told me not to put the row in and it was working that way for all but the one field. Unless my syntax is incorrect, I will have to remove the row.
Randy Jacoy
Veteran Member Send Private Message
Posts: 46
Veteran Member
Lynne, You mentioned the fields you are looking at are in a detail area.  I believe you need to reference the LINE-FC variable, not the FC varaiable.  The FC variable indicates which action button was clicked (Add, Change, Inquire, etc).  The LINE-FC variable will give you the value of the FC field in the detail area.  You can reference it as follows:

  if (fc == "A" || fc == "C")   //  <-- this is testing for the main form action (add or change)   {     for (i = 0; i <= 4; i++)  // <-- this is iterating through your 5 detail lines.     {       //Check for Detail Area for required fields if adding or changing a line.       dlLineFC = lawForm.getDataValue("LINE-FC",i);

      if (dlLineFC == "A" || dlLineFC == "C")   // <--- this is checking the action selected in the detail line FC.        {             // do some stuff         }     }   }

Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
I took the row out, retyped my 'if' and now all fields in the line work except for fc1. I'm thinking that field fc1 just does not work for what I'm trying to do. The fact that you cannot click on it in the object to see the field id makes me wonder. I looked in the source to find the id. That will just be a training point.
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
Randy, I want to know when they click on the function lines, so I have my code in the OnFocus function. I just put an alert in to display "id" in the function, and nothing happens when I click on the function field of the line. It doesn't seem to respect the OnFocus. Thanks! function TEXT_OnFocus(id, row) { alert("id " + id); if (id=="text17" || id=="text12" || id=="text13" || id=="text14" || id=="text15" || id=="text16") // This works, fc1 does not
Randy Jacoy
Veteran Member Send Private Message
Posts: 46
Veteran Member
Lynne, The detail line FC field is a select field, not a text field so the TEXT_OnBlur doesn't fire when it changes.  You'll need to put your code in the VALUES_OnBlur function.  That will fire when you change a select field.  Try putting your alert there and experiment with changes.  For example:  if(id == "select2" && lawForm.getFormValue(id) != "")  // <-- this tests a field called select2 and makes sure a value was selected.  {   var myValue = lawForm.getFormValue(id);   alert("select2 value is " + myValue);  }   
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
Thank you so much, Randy. I will do some testing.
Lynne
Veteran Member Send Private Message
Posts: 122
Veteran Member
It works now, Randy, using the VALUES_OnFocus. Thank you for solving my last problem (for this project).
Randy Jacoy
Veteran Member Send Private Message
Posts: 46
Veteran Member
Glad I could help Lynne.