Servicenow UI Policy Script to reference fields pulling data from referenced field - servicenow

I am trying to find a way to create a UI Policy script that will reference other field in a project (name and description) from the above defined parent field. The parent field is a reference field, so the dropdown icon to the right of the text is working. I would like to learn how to have additional reference fields that reference other data field within the defined Parent field.
I am new to this, so any help would be appreciated. This is the script I have put together thus far.
function onCondition() {
var x = g_form.getReference('parent');
g_form.setValue('u_prj_short_desc', x);
g_form.setValue('u_prj_desc', x);
}

Related

How can i do a dynamic SelectOneRadio in ADF with CollectionModel binding?

im trying to do a SelectOneRadio that was linked with a binding in ADF.
Mi binding have this structure:
Parent named "Group" (ID, Group, Orden).
Child named "Action" (ID, Action, Desc).
I want one radio group for each "Group" with each "Action".
The web don't have error or i cant see it.
And if i can do this, can i get the value of each radio group?
Thanks for all.
I will first check if the value set on af:iterator is returning expected number of values/rows/items. Then I will check if each of those row item has children property, and see if that too is type of List (or related types). If you follow these two instructions, you will know why this isn't working.

Servicenow - Service Catalog Reference Field - Insert different column than the display value

Let me describe my problem:
I have a table for all my IT-Services. I reference to this table more than once, for different purposes. Most of the time I need to reference to the name of the service. That's why I keep the name as displayed value.
One Column of that table is a service_id (custom field) which is for example "Service_004". Now in a catalog request Item the User has to fill in the service_id in a reference field.
But since I have the name as displayed value, and I need it in other forms, I am unable to reference to the service_id.
Using the variable attributes field I managed to let the service be found using the autocomplete function. But in the reference field I still get the servicename. I know that I can change the display value in the dictionary, but this breaks other functions. So what I need is to change the display value just for one reference field.
Also I tried to create a new table called IT-Services2 with reference to my table IT-Services. Then I switched the display to true in the new table for my service_id, but this will even change it in the parent table.
Perhaps an onChange client script utilizing g_form.setLabelOf() ?
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf
Maybe I'm not fully understanding your question...
I ran into this issue before, what you can do is create select box variable and use an on load client script to populate the list with the service_id(s) from the table you are referencing.
I would write a script include to pull the data from the table and call it from the client script via GlideAjax.

Joomla Component Dynamic Custom Field based on other Field Value

I am creating a new Joomla Component. I am able to create custom fields for the component backend forms - but I am not able to create Dynamic Custom Fields.
What I would like to do is have a field that is dynamical populated based on the value of a previous field. The easiest way to explain this is the simple country,state,city breakdown.
Field 1 = Country
Field 2 = State (Based on what the user selected as as Country in Field 1)
Field 3 = City (Based on what the user selected as State in Field 2)
The fields would of course need to be refreshed, reset as the user picks a different country etc.
The data to populate the fields would also all need to come from a database based on the previous fields value.
I am guessing this needs to be done via ajax or javascript or something? But wondering if there is an official way? Especially since there are database calls involved.
Please let me know if there is anything I can explain better..
David
I ended up just creating text fields but then validating the input to make sure the values added are correct.

Getting Document Collection in Lotus Notes using the Form UNID

I have the UNID of a Lotus Notes form. can i use this UNID to get the Document Collection of that form ??
I am using the NotesDatabase.Search() method to get the document collection. But this query only works if it is provided with the Form Name. Does not works works with the Form UNID.
I am trying to do this because in my application there are two forms with the same name and Alias name.
Short answer: This is NOT possible.
Documents are linked to the Form via their own Form- item. This is a textitem and contains the alias of the form they were created with. There is NO further relation between the form that was "really" used when creating a document. As soon as you create another Form with that alias and delete the old one, all documents will use the new one. As long as there are 2 forms with the same alias, one of them will be used by chance (usually the one with the smaller NoteID will be used, but this can not be guaranteed).
If your question is to find out, which documents where created with which of the forms the only possibility is to select them according to special fields in the forms. If e.g. one form has an item "CreatedDate" and the other does not, then you could select #IsAvailable( CreatedDate )
Unfortunately if you open a document that was created with the "old" form and save it, it will also have the new item... So this will never be a 100% solution.
To make it even harder: One could create a document using LotusScript and in the end just fill the Form- item: doc.Form = "SomeForm". Then the document was not created with either of your two forms...

MS CRM - getting the field that caused a form save

I have a MS CRM 4 form where when certain fields are changed, I need those fields to be written to an excel sheet.
So, I edited the form field onchange event to call crmform.save() which triggers a plugin to run that writes the field value to a named range (1 cell) of an excel sheet.
However, I don't know which field caused the save. Is there a way to get that information? (Not all fields on the form need to go to the excel sheet)
If I use this: DynamicEntity target = (DynamicEntity)Context.InputParameters[ParameterName.Target];
I can look at specific fields, but I have no way of knowing which ones changed.
Any suggestions?
It's my experience that only the changed fields will have value (in the DynamicEntity) when you update an entity. So let's say you have an entity with a FirstName and Lastname. If you only change the LastName and save. The LastName will have a value however FirstName with be null (unless you have som javascript code that forces the FirstName to be submitted).
If your plugin is triggered on the Pre-Event of the Update on your entity, you should be able to compare the IPluginExecutionContext.PreEntityImages to your DynamicEntity that you've fetched from the Target.
Or if your plugin is triggered on the Post-Event of the Update, you should be able to compare the IPluginExecutionContext.PreEntityImages with IPluginExecutionContext.PostEntityImages.
Looks like you are already going a different way, but another suggestion is to create a hidden field - "FieldThatChanged." In your field on-change javascript, set that field to the name of the field that changed, then access that in your plugin.
Yep, totally changed the way I approached this. I'm using jquery in an iframe to pass all the exact fields (name/value pairs) I want to a method of an ASPX file running in the ISV folder that takes the neccesary action. Thanks for the suggestions all!
I recommend using the Pre and Post Images as suggested by #Forgotten Semicolon. And in addition set the Filtering Attributes so the Plugin is triggered only on the change of the fields you care about.

Resources