Caller field reference qualifier dependent on Company OR MyCompany

ralphalberti
Kilo Expert

I have a simple reference qualifier setup for the Caller field which is dependent on the Company field. Works fine.

My issue is that I need the reference qualifier to allow Users from the value in the Company field OR my own Company which is called Novitex.

Can I create this OR using the Condition Builder or do I need javascript? I'm not really a coder but can usually get by with some examples.

The Dependent field is Company.

Screen Shot 2017-07-27 at 5.33.53 PM.png

13 REPLIES 13

Priya Shekar
Giga Guru

Hi Ralph,



You can add your condition in the reference qualifier and set the company field to "YOUR Company".


This will give you the users of your company in the caller field.


No scripting is required.





Thanks,


Priyadarshini




PS: Hit like, Helpful or Correct depending on the impact of the response


Thanks for the suggestion. I thought I had tried that already and did again just now. Didn't work. Am I missing something?



Novitex.png


Michael Fry1
Kilo Patron

You can remove the dependency on company, and use a script includes to get the current company and your company.


For the caller field, add this plus the name of the script includes: javascript:getCompanies() (getCompanies() is example)



Then script includes looks like this:


function getCompanies() {


     


      var retval = "sys_idIN";


     


      var comp = new GlideRecord('sys_user');


      var qc = comp.addQuery('company', current.company);


//change sys id to your company


      qc.addOrCondition('company', 'df7d53303710200044e0bfc8bcbe5dac');


      comp.query();


      while (comp.next()) {


              retval += comp.sys_id + ",";


      }


      return retval;


}


Your suggestion looks exactly like what I need but I'm having difficulty implementing it.


I haven't used script includes before so I am not exactly sure how to implement your suggestion.



I see a framework automatically inserted into the include when I create it but I am not sure where to drop your code in or replace that framework altogether. If I drop your code in, I receive a couple of errors about missing brackets. Also not sure about the Javascript call that goes into the Reference qualifier field.



I named the Script Include enhancedCaller



Here's where I am at currently;


Javascript Call


Javascript call.png



Script Include


ScriptInclude.png