logo

NJP

Servicenow Portal (Part 12b) - Ticket Conversation

Import · Nov 23, 2019 · video

Aslam o alaikum everyone I'm back with another video of ticket conversation so last day on my video I have told you to try yourself with the business rule and I have given you the hint and today I'll be showing you how the update will happen in the audit history of the field which we have created for the ticket conversation so here we go with the business rule first of all it will be the before insert or update because I want the history chat is free to update whenever we are updating so before we are updating any field we will capture it in the array and we will push it in the journal input field so let's give it an EMS update ticket conversation field now I will do it advanced because and before and insert and update ok so any idea what we will write so basically we will first take all the field names and all the field values in which the user is updating or while inserting the record so these are out-of-the-box function which is there in ServiceNow from where we can get all the database field and the values which you are changing so let's write where let's take it variable GRU equals to glide script record util dot gate current okay this is the function where we will get all the this is the function actually which is there in the service now to get all the fields and values of this current table record so now we will take one changed DB field field equals to gr u dot gate changed field names okay however now next variable I will take to the values which is getting changed is equal to gr u dot gate changes okay next I will take as changed fields it's it's just a field which will get changed our nickname type dot gate changed fields okay now the thing is I will just change this into the JavaScript array so I'll just put a comment as convert to JavaScript array now here what I will do I will first use GS not include and in this I will write J - J s now what I will do is I will take this change DB field equals to J 2 J s and the same name it will just convert this is also out of the box thing this is equals to J 2 J s this changed field equals to J 2 J is this ok now we will write one for loop ok for loop because the number of fields you are changing it will take all it in the length means changed values dot length because the number of values that is getting changed say it will take that and it will push it in the area accordingly so first I will take current value as the object and I will take one previous value orchard previous value variable and I have left I have didn't write the array initialized sorry I will initialize it to your the array so current value and previous value have written now if current dot operation equals to equals to insert ok then we will just give the current value equals to glide evaluator dot evaluate string and inside a valid current dot the field name change DB field at I plus dot gate display value okay so this will be pushed to the a do not push give the backslash n first in the next line it will change everything according to the change fields I will take now you will understand the purpose of change fields actually by ever I have taken try to field names with : plus current value the value which have changed through this okay and that's should I hope you guys are getting everything what I am writing here worry it's basically current value current field the value I am taking and I am pushing it into the array now else if it is not insert if it is update then what I will do I will take the previous value equals to same light evaluator dot evaluate string I will just copy this okay over here I will write devious okay change DB field at I don't get is below or display value now if previous value is empty then we will put it as empty okay if now current rally I will give the same and if current value is also empty then we will make it as current value equals to empty so basically why I am doing this is because for some times if we are changing the value from blank to something so the previous the current value was blank so it will give us empty to that so that particular statement I will push it in the array array Val sorry Ravel dot push and the statement goes like in the new line with the changed field at I + : plus we will take the field first previous value we will give now again I will give space as then changed - and then I will give the current value its previous value changed to current value okay now if the current value is empty and previous value have given something then it will write as this will have changed from this change to empty because I'm mentioning it here empty now after all these loop has happened I will push this I will update that into my field which I have created your audit history equals to a devel dot to string okay now I will just submit this okay so previously I've showed you how it was not getting updated because all the we were updating in the in the back end but it was not inflating in the portal and we were updating it here as well but it was not getting visible so let's try once again first I will just write SS here so that and if I save so now if you see user this changed to this which I have given it previously so if I do it in the admin okay because we will say I'm given systems the same example which I have given earlier and it was not reflecting in my portal so just give it administrators and I will just receive okay and now when I will go in the form and I've given the filter here actually I've enabled that sorry society yes I will give it the society here and I will run let's open and here we go now change to systems administrators last me null change to administrators so basically by two are coming because I have changed in the last name and the name also there is a background script where background business business rule which just update the name as well which is not visible here but the name is there in the form if you want you can bring it in the form layout so now if you just inactive this one nothing will work and just show you I have been activated this let's just change in the form and see whether it is getting updated or not let's make this ad - admins and I will save it and if I go if you see it didn't get updated here okay so this is what Russell was about I'll revert this back so I'll just make this active first so I'll just remove this s and then save it now so yeah here we go here we go with the business tool thank you guys for watching now in the in my next video I will show you there will be one button on clicking of which this activity will be visible and this form will come so if thank you thanks for watching

View original source

https://www.youtube.com/watch?v=uYKP14RGmLY