Set "General Information" on entity programmatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Set "General Information" on entity programmatically
Hello Community,
I am looking for a way to set entities "General Information". In particular I am looking to set the "Login Style", "Login Prompt" and possibly some other things of an organization from a service.
I could find a "SetHomeMashup", but I can't seem to find any other service that fulfills this requirement.
Does anyone have any ideas?
Thanks,
Jens
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I also do not know of any service to do so.
What would most likely work is hacky and not nice to use (did not try it myself).. But if you really need it:
1. Use entityAsJson = Resources["EntityServices"].ReadEntityAsJSON with type "Organizations" and name "yourorgname"
2. In the result adapt login prompt e.g. entityAsJson.loginPrompt="Hello world"
3. Save the entity by creating a PUT request with ContentLoader functions to http://localhost/Thingworx/Organizations/yourorgname with the entityAsJson in the body (the same what composer does when you save the entity)
To make the request you will need an appkey with the needed permissions and pass it as a header...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I belive, we can't updat the "General Information" in single go. We have update each parameter separately.
Example:
Things["SecurityMonitor"].SetAvatar({
content: undefined /* IMAGE */
});
Things["SecurityMonitor"].SetDescription({
description: undefined /* STRING */
});
Things["SecurityMonitor"].SetProjectName({
projectName: undefined /* PROJECTNAME */
});
Things["SecurityMonitor"].SetTags({
tags: undefined /* TAGS */
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Sathishkumar_C,
Thank you for your reply.
Yes I do think this is the way to do it. Unfortunately there is no service for setting the information I want to set:
Like setting the login prompt etc...
It does seem unlikely that there is a way to do this though...
Thanks,
Jens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
not sure on login prompt.
you can use following service to updat the style definition.
let params = {
name: undefined /* STYLEDEFINITIONNAME */,
content: undefined /* JSON */
};
// no return
Resources["EntityServices"].UpdateStyleDefinition(params);
please refer Style definition using scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
This updates a style definition, it doesn't set which style definition to use on an organizations login style.
But thanks anyway!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I also do not know of any service to do so.
What would most likely work is hacky and not nice to use (did not try it myself).. But if you really need it:
1. Use entityAsJson = Resources["EntityServices"].ReadEntityAsJSON with type "Organizations" and name "yourorgname"
2. In the result adapt login prompt e.g. entityAsJson.loginPrompt="Hello world"
3. Save the entity by creating a PUT request with ContentLoader functions to http://localhost/Thingworx/Organizations/yourorgname with the entityAsJson in the body (the same what composer does when you save the entity)
To make the request you will need an appkey with the needed permissions and pass it as a header...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @nmutter,
I did a test and this absolutely worked!
Perhaps as you say it is a little bit hacky, but as I do not see any other way of doing it, this will have to work.
Thanks,
Jens