creating an action log entry with javascript
I am attempting to create an action log entry as part of a custom task. I get an undefined error when attempting to push the new action log entry using the .push() function in the AppliesToTroubleTicket object. Any guidance would be appreciated.
Best Answer
-
Roland_Kind Partner Advanced IT Monkey ✭✭✭
Hi,
could you please try to change the following line:
AppliesToTroubleTicket.ActionLog.push.apply(newActionLog);
to:
pageForm.viewModel.AppliesToTroubleTicket.push(newActionLog);
this seems to be working (latest portal Version 8.2 / scsm 2016)
regards
1
Answers
Hello,
if possible - could you please post the js script - it might be easier for tracking down the problem :-)
regards
Hi,
could you please try to change the following line:
AppliesToTroubleTicket.ActionLog.push.apply(newActionLog);
to:
pageForm.viewModel.AppliesToTroubleTicket.push(newActionLog);
this seems to be working (latest portal Version 8.2 / scsm 2016)
regards
Hello, I've come across another question concerning a similar issue as we were discussing earlier. The script I have here works as long as the user is an analyst. When I switch over my test user it fails on viewModel.RelatesToTroubleTicket.set statement. I've track it down to the fact that is RelatesToTroubleTicket doesn't load for an end user until after the ticket is resolved. Since the users i'm building this for are end users I need to load the RelatesToTroubleTicket before setting who resolved the request. I've tried the init, set, get functions on the pageForm.viewModel but I am unable to get this to load using javascript.
Would you or anyone else have any insight as to how I can load this object into the view model with the script I've posted above?
Thanks in advance.
Hi Jarrett,
just a very quick solution - please try this - should work
just add the following lines to your .js file
... (cut from your file)
//beta method
pageForm.viewModel.AppliesToTroubleTicket.push(newActionLog);
var newRel;
newRel = {Name: "RelatesToTroubleTicket", RelationshipId: "f7d9b385-a84d-3884-7cde-e2c926d931a5"} ;
pageForm.viewModel.NameRelationship.push (newRel);
pageForm.viewModel.RelatesToTroubleTicket = {
"ClassTypeId": pageForm.viewModel.ClassTypeId,
"BaseId": session.user.Id,
"Id": pageForm.viewModel.Id
};
var curDate = new Date();
pageForm.viewModel.ResolvedDate=curDate.toISOString();
.... (remaining part of your file)
regards
Roland
This works exactly how i figured it would need to. How did you find the RelationshipID. I don't understand where this information is stored or where i can find it to try to figure these things out on my own. Is there documentation you could point me towards?
Thank you for all the help on this. I just have to try to figure out how to get the selection from the enum pickers to pass the IDs back to the viewModel so it sets the correct classifications and resolution categories.
The simplest way would be to open an Incident in your browser, then open the browser's Developer Tools and type
into the Console tab.
This will give you an object showing all the relationships mapped to the view model. Just look for the relationship you want and you will find the RelationshipId.
Hi Jarrett,
great :-) & depending an what you need regarding the enums pickers the following links maybe helpful:
https://community.cireson.com/discussion/comment/11444#Comment_11444
https://community.cireson.com/discussion/comment/4354#Comment_4354
regards
Roland