Record Producer variable linked to reference field not taking a value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 07:46 AM
Hello,
I have just finished deploying a large update set from o_ur Test environment to Production and most of it has worked exactly as planned in production with the exception of 1 really irritating bug that I have found.
Test was cloned to Production before we went live with SN a few months ago and this deployment today pretty much brings them back to the same code base after we added a new custom app.
Production is running : glide-geneva-08-25-2015__patch6-hotfix2-05-18-2016
Test is running : glide-geneva-08-25-2015__patch6-hotfix2-05-18-2016
I have circa 25 record producers with their own tables, all extended from one parent table that extends Task. On the record producers, I have a variable set for common variables across all the Record Producers. In that called set, I have a variable called Opco which is the Company field on the Task table basically, a reference field to core_company.
In the variable set there are a number of Catalog Client Scripts to set some values on the new record producers, one being to go and grab the current user's Company and put it on the new record in the company field/variable. There is some logic around when this runs - if a user is an admin the field isn't set because they can raise tickets for all users in all companies. If the user is not an admin, the field is set with their own company and then made readonly so they can't change it on the record producer.
The Catalog Client Script makes an Ajax call to a function that checks if you're an admin or not, and if not it returns the sys_id of the user's company record.
The Client Catalog Script then runs this code to set the Company reference variable on the Record Producer:
In Firebug I see the Client Script message with a valid sys_id and the company variable contains the name of the user's Company - all works perfect in Test.
In Production however I see a totally weird behaviour. The first time the Record Producer loads for a new session, the company name is populated correctly , and the field is set to read only.
The next time I load the record producer or go to another one that shares the same variable set, the script runs, the console log in Firebug shows the sys_id of the company, and I can see that the field is no longer mandatory and it is read only, BUT the company name does not display and for some reason the field has collapsed to around 40% of the normal width. There's also no button to open the related record.
I have tried everything! I removed the Set Mandatory and Set Readonly commands in the Client Catalog Script, and reload the page to see a company name present. Then reload again and it's not there any more. The field remains visually correct however, it does not shrink. So it's the ReadOnly function that seems to cause the field to shrink for some reason. That's one half of the problem, the other is that the company doesn't display. It's erratic behaviour - make a change to the script and I get this again (the correct behaviour)
reload the page again and I get this :
This happens consistently in our Production environment only, in both Chrome and IE 11, and Chrome on Mac.
For now I have had to remove the script that sets the field to be mandatory and readonly but the business have a requirement to prevent users raising requests outside of their own company. I can't even get it to reliably populate the opco variable even with the readonly and mandatory code removed, most of the time the page loads and I just see :
Does anyone have ANY ideas what could be causing this or how to fix? I have been looking at it all day, and in Dev and Test where the code is identical to Production for the client scripts that are running here, it has always worked. The fact that every now and then I get a company name populated surely means it's not an ACL issue - but I have checked the Access for the users and can browse the core_company table and view the records there so I'm pretty sure it's not that.
It's just being WEIRD!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 10:36 AM
There is 1 Warning in the console and 2 errors - not sure where I go to track these down but I think they might be red herrings - the same 3 messages are present on our Test environment where the code works flawlessly
Warning:
and 2 Errors like this :
I'm not aware of any DOM manipulation on the Record Producers - they were built by a technical partner who might have added code to do this but my team hasn't added to it certainly. I have seen DOM manipulation elsewhere in the system though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 11:18 AM
OK, so two suggestions (both came from HI, re migration to Helsinki😞
1. Find your getXMLWait scripts and change them to getXML, as per this article: GlideAjax - ServiceNow Wiki section 2.1.2
2. Incidentally, I see you have almost the same error that I had - in your second screenshot, with the com.glideapp.servicecatalog_cat_item_view in the first line. I do not know if this is related, but in my case (Helsinki), the technical partner who made the ess changed the code for that file. It worked flawlessly in Dublin and Eureka, but caused problems in Helsinki. After HI pointed this to me, I reverted it to Helsinki OOB com.glideapp.servicecatalog_cat_item_view and things were fixed. So, I am not 100% sure this is the cause of your problem but you might want to give it a try.
i don't know why this is working in Test but not in Prod. In my case, I cloned Prod to Dev and everything worked. On the second clone, issues occurred. HI couldn't tell me either why it happened...
Harel
Edit:
And if you're apprehensive about making changes in Prod, open a case with support, I guess
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 11:54 AM
Thanks Harel for all the suggestions. I'll take a look at that script you mentioned tomorrow with my team and post back any findings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 02:26 PM
I sadly think the getXMLWait is the bad of ServiceNow, unless Andy got some more scripting on the loading, since there wasn't any of them in his script.
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 02:25 PM
It real strange and I hate when an error isn't consistent. it feels like a ACL, but like you said it then it shouldn't work sometime. I can think of that it might be something that you set the sys_id of the group, but before it get a reply from the server that it has found a match, it puts the readonly in the field, and then it returns with the "display value" but can't put it there since the field is read only. And sometimes it's the other way around, making it work when the server response faster than the read only sets in.
I'm thinking more of a solution perhaps like this.
Since it's a record producer, you can hide the variable if the user isn't a admin, then set the value in the script part of the Record producer. Wouldn't this solve your problem as well? Another way is to put the code in the default value of the variable and keep it hidden for none admins.
Anyone of those works?
//Göran
