View Model values documentation
![Jeff_Landers](https://us.v-cdn.net/6026663/uploads/userpics/047/nN0X1U14400A4.jpg)
I am trying to use viewmodel values but can't seem to guess them. Is there a list of all the values and what they represent? Many are obvious but some are not. I couldn't figure out (even with the form up and developer running in Chrome) that viewModel.AssignedWorkItem was actually the user field and viewModel.SupportGroup was case sensitive. I am now trying to figure out the Incident Classification which may be class but...........
How do you guys know what is what?
Best Answers
-
Geoff_Ross Cireson Consultant O.G.
Hi @Jeff_Landers
Shane is right, as per that article not all pages have a viewModel but if you are talking about WorkItem / ConfigItem pages, they will all do.
How do you know whats is what?? You just have to know...
No seriously, you can look things up but you are subject to the odd names that SCSM (and maybe Cireson) has given some things and also a mis-match between property internal names (which is what the viewModel will use) and property display names which you might be used to.
The viewModel is complex combination of 3 things.
1) The properties of that object (including end extended ones)
2) The relationships in the configured type projection
3) A few portal only concepts (such as Watch List)
1) You can look these up with Powershell. You need to look at the Name and Displaynames here, the viewModel will use Name (internal name) but you might know things by their DisplayName. The classic example is Support Group on an Incident which is actually called TierQueue internally.PS C:\> Get-SCSMClass System.WorkItem.Incident$ | Get-SCSMClassProperty | Select DisplayName, Name DisplayName Name ----------- ---- Resolve by TargetResolutionTime Escalated Escalated Source Source Status Status Resolution description ResolutionDescription Needs knowledge article NeedsKnowledgeArticle Support group TierQueue Has created knowledge article HasCreatedKnowledgeArticle Last modified source LastModifiedSource Classification category Classification Resolution category ResolutionCategory
2) You can look up the Type Projections in Powershell too. By default your forms will be using the Cireson ones but you can change this to support custom relationships. This will show you the relationships in the Type Projection by Alias and Target End Point. Again, you will likely know them by Alias but the viewModel will use TargetEndPoint. You will see that AssignedTo (the assigned user field) will be known as AssignedWorkItem in the viewModel.PS C:\> Get-SCSMTypeProjection Cireson.Incident.ViewModel ProjectionType: Cireson.Incident.ViewModel ProjectionSeed: System.WorkItem.Incident Components: Alias TargetEndPoint ----- --------------- PrimaryOwner RelatesToIncident AssignedTo AssignedWorkItem AffectedUser RequestedWorkItem CreatedBy CreatedWorkItem AffectedConfigItems HasRelatedWorkItems RelatedConfigItems RelatesToConfigItem ActionLogs AppliesToTroubleTicket UserComments AppliesToTroubleTicket AnalystComments AppliesToTroubleTicket Activities Activity FileAttachments FileAttachment SLAInstances Target ParentWorkItem ParentWorkItem ChildWorkItem ChildWorkItem ResolvedByUser RelatesToTroubleTicket RelatedWorkItem RelatesToWorkItem_ RelatedWorkItemsSource RelatesToWorkItem BillableLogs AppliesToWorkItem ClosedByUser RelatesToTroubleTicket
3) These will vary depending on settings, config, version etc but the best way to see these would be to use the Developer Console in your browser (I find Chrome the best by far for this sort of thing) and typepageForm.viewModel
Finally, as you mentioned, being JavaScript based, the viewModel is case sensitive. You need to use the casing exactly as output in the Powershell. Its slighty confusing as its a mixture of camelCase which is JavaScript convention (what the portal uses) and ProperCase which is C# convention (what SCSM uses)
Good luck, hope this helps.
Geoff8 -
Geoff_Ross Cireson Consultant O.G.
Jeff,
Building a comprehensive list of guids... a good place to start is app.constants
Type that in the browser console and have a browse.
Geoff5
Answers
Hope you are well, this sounds similar to another case in this Community thread:
https://community.cireson.com/discussion/4018/how-to-target-the-viewmodel-when-there-is-no-pageform-object
Could you have a look at this and let me know if this helps at all?
Thanks,
Shane.
Shane is right, as per that article not all pages have a viewModel but if you are talking about WorkItem / ConfigItem pages, they will all do.
How do you know whats is what?? You just have to know...
No seriously, you can look things up but you are subject to the odd names that SCSM (and maybe Cireson) has given some things and also a mis-match between property internal names (which is what the viewModel will use) and property display names which you might be used to.
The viewModel is complex combination of 3 things.
1) The properties of that object (including end extended ones)
2) The relationships in the configured type projection
3) A few portal only concepts (such as Watch List)
1) You can look these up with Powershell. You need to look at the Name and Displaynames here, the viewModel will use Name (internal name) but you might know things by their DisplayName. The classic example is Support Group on an Incident which is actually called TierQueue internally.
2) You can look up the Type Projections in Powershell too. By default your forms will be using the Cireson ones but you can change this to support custom relationships. This will show you the relationships in the Type Projection by Alias and Target End Point. Again, you will likely know them by Alias but the viewModel will use TargetEndPoint. You will see that AssignedTo (the assigned user field) will be known as AssignedWorkItem in the viewModel.
3) These will vary depending on settings, config, version etc but the best way to see these would be to use the Developer Console in your browser (I find Chrome the best by far for this sort of thing) and type
Finally, as you mentioned, being JavaScript based, the viewModel is case sensitive. You need to use the casing exactly as output in the Powershell. Its slighty confusing as its a mixture of camelCase which is JavaScript convention (what the portal uses) and ProperCase which is C# convention (what SCSM uses)
Good luck, hope this helps.
Geoff
Shane.... Yes I have looked at that link and others.
I have been pinging James Kleinschnitz who has been helping me with some code and viewModel names but I was looking for more. Thank you.
Geoff, That is the best "documentation" I have seen on the viewModel. I am trying to build a comprehensive list of guid's (status's as an example) and viewModel fields to make writing the custom code faster.
I know this is a lot to ask but if someday there were a complete list of form names/functions, related viewModel fields, and which ones we can actually change, it would help those, like me, who are new to javascript.
Thank you again for taking the time to educate this rookie.
Jeff
Building a comprehensive list of guids... a good place to start is app.constants
Type that in the browser console and have a browse.
Geoff