Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
I need to get the input from the front end mashup then i like to create the style definition based on the input using services, further i like to update the particular widgets style definition with that newly created style.
thanks in advance...
Solved! Go to Solution.
Combining both and after some tests, this is the correct format :
var name = "NewTestStyle3"; try{ Resources["EntityServices"].CreateStyleDefinition({ name: name, description: undefined , content: { "content" : { "params": "", "image":"", "backgroundColor":"#d49d13", "textSize":"normal", "lineStyle":"dotted", "displayString":"Series 15", "fontEmphasisUnderline":false, "fontEmphasisItalic":false, "lineThickness":1, "lineColor":"#ffac20", "foregroundColor":"#ffdc84", "fontEmphasisBold":false, "secondaryBackgroundColor":"#ffb22f" } }, tags: undefined }); }catch(err) { logger.error("EERROR STYLE CREATION "+err); Resources["EntityServices"].DeleteStyleDefinition({ name: name }); }
There is a snippet:
var params = { name: undefined /* STRING */, description: undefined /* STRING */, content: undefined /* JSON */, tags: undefined /* TAGS */ }; // no return Resources["EntityServices"].CreateStyleDefinition(params);
But I don't know how to use it properly. I am curious about how to do this too.
thank you for your reply xavior,
i know there is a separate snippet available in the service part. but i also dont know how to use that one.
In that snippet where do we need to give input for color code and text format?
If you look at my answer on how to get Style Information: https://community.ptc.com/t5/ThingWorx-Developers/Get-style-information-of-style-definition/m-p/548275
you can see that the context format for style may look something like:
{ "image":"", "backgroundColor":"#d49d13", "textSize":"normal", "lineStyle":"dotted", "displayString":"Series 15", "fontEmphasisUnderline":false, "fontEmphasisItalic":false, "lineThickness":1, "lineColor":"#ffac20", "foregroundColor":"#ffdc84", "fontEmphasisBold":false, "secondaryBackgroundColor":"#ffb22f" }
Combining both and after some tests, this is the correct format :
var name = "NewTestStyle3"; try{ Resources["EntityServices"].CreateStyleDefinition({ name: name, description: undefined , content: { "content" : { "params": "", "image":"", "backgroundColor":"#d49d13", "textSize":"normal", "lineStyle":"dotted", "displayString":"Series 15", "fontEmphasisUnderline":false, "fontEmphasisItalic":false, "lineThickness":1, "lineColor":"#ffac20", "foregroundColor":"#ffdc84", "fontEmphasisBold":false, "secondaryBackgroundColor":"#ffb22f" } }, tags: undefined }); }catch(err) { logger.error("EERROR STYLE CREATION "+err); Resources["EntityServices"].DeleteStyleDefinition({ name: name }); }