8 Replies · Latest reply on Dec 8, 2017 5:18 AM by Scott Eberly

    parent in UI action is undefined

      After upgrading to Istanbul, we found the "New" UI action on time_card (which is new in Istanbul) was erroring out due to "parent" being undefined. This is causing the button to not work. The UI action works perfectly in my dev instance. I found this wiki article which explains you can reference parent in a UI script (although that is in the context of the condition and old), so given the evidence I would assume there is a update to something we did not get (skipped) in an upgrade. I can't figure out what it is though. Any help is appreciated.

        • Re: parent in UI action is undefined
          Göran Lundqvist

          Parent only works with UI Actions in related lists. Is this the case?

           

           

          //Göran

          //Göran

          ServiceNow Witch Doctor and MVP
          -----------------------------------
          For all my blog posts: http://bit.ly/2fCzj1g

            • Re: parent in UI action is undefined
              Scott Eberly

              Correct, but it should at least be null (not undefined) when you're not on a related list.  At least that's the way it's behaving my dev instance.

                • Re: parent in UI action is undefined
                  Adam Kaupisch

                  I'm running into the same issue...I'm trying to do a New button on a Test Case Instance related list and parent is showing as null...I do this on many other tables and it's just find. Any resolution in your case?

                  Please Like, Mark Helpful, or Correct Answer if it applies.

                    • Re: parent in UI action is undefined
                      Scott Eberly

                      In our case we couldn't figure it out so we just deactivated the out of the box "New" button on time_card and our global "New" button took over.  We will address further soon when we upgrade to Jakarta and move to Time Sheets (currently we are still just utilizing Time Cards independently).

                       

                      I will try to remember to follow up when we get there.  Sorry I couldn't be of more help at this time.

                        • Re: parent in UI action is undefined
                          Adam Kaupisch

                          So I think I figured it out. There are some related lists where it's possible that you can have 'many' parents. This confuses SN and as a result they set parent to null. What's crazy is using parent in the condition statement still works just fine...probably a bug, but whatevs...anyway, the solution I had was the following: Check 'Client' in the UI Action, add a client function that makes an ajax call to a script include that generates a URI for you...then redirect to that location...here's the code I'm using and it seems to be bomber so far... Hope this helps.

                           

                          ui action.png

                          script.png

                          Please Like, Mark Helpful, or Correct Answer if it applies.

                            • Re: parent in UI action is undefined
                              Scott Eberly

                              Adam,

                               

                              This is great documentation.  The issue we were running into was a bit different, however.

                               

                              The new button introduced in Istanbul on time_card was meant to be used on a time_card related list (i.e. a related list on the time_sheet form) not just a standalone time_card list (i.e. time_card_list.do).  Since we weren't using time_card as part of time_sheet, clicking the button on time_card_list.do resulted in parent being undefined because it was supposed to refer to the time_sheet the time_card was on, but because time_card_list.do there isn't one, parent is now undefined.

                               

                              Thanks for your response!

                              Scott

                                • Re: parent in UI action is undefined
                                  Adam Kaupisch

                                  Perhaps I'm not fully understanding what you are trying to do...we, too, don't use time sheets and we allow folks to create a time card off any task in the system.

                                   

                                  The OOB time_card New button only uses parent to set some params to pass into the time_card; specifically week_starts_on and user...neither of which you really need as you can get them other ways...there's no other reference to parent once you create the record...So parent is kinda pointless at this point.

                                   

                                  We completely overwrote the New action for time_card and basically generate our own uri (similar to above) instead of using the wizard. If you're doing this from a ref list and need the 'task' that you are on (what is traditionally the 'parent' when you are in a ref list), then you can pass that in via the method mentioned above.

                                  Please Like, Mark Helpful, or Correct Answer if it applies.

                                    • Re: parent in UI action is undefined
                                      Scott Eberly

                                      In summary, the "New" UI action wouldn't work on time_card after upgrading to Istanbul.  We found that there were errors in the logs stating that "parent" was undefined.

                                       

                                      After reviewing the code we didn't see a need for any of the extra stuff the code was doing so we ended up doing something very similar to what it sounds like you did.  We just deactivated the out of the box UI action and utilized our global "New" UI action.