cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Set "General Information" on entity programmatically

jensc
17-Peridot

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

1 ACCEPTED SOLUTION

Accepted Solutions
nmutter
14-Alexandrite
(To:jensc)

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...

 

View solution in original post

6 REPLIES 6

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 */
});

 

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:

jensc_0-1685513581089.png

Like setting the login prompt etc... 

It does seem unlikely that there is a way to do this though...

 

Thanks,

Jens

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

 

Hello,

 

This updates a style definition, it doesn't set which style definition to use on an organizations login style.

But thanks anyway!

nmutter
14-Alexandrite
(To:jensc)

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...

 

jensc
17-Peridot
(To:nmutter)

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

Top Tags