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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

I want to append image to string/text while writing service

nbhagtani
2-Guest

I want to append image to string/text while writing service

Please check below service code:

var connections;

if (filter == "blank") {

  connections = Networks['FlowServeNetwork'].GetNetworkConnectionsWithTemplate();

} else {

  var params = {

  start : filter

  };

  connections = Networks['FlowServeNetwork'].GetSubNetworkConnectionsWithTemplate(params);

}

var params = {

  dataShapeName : "FlowserveTreeNetwork",

  infoTableName : "AssetHierarchy"

};

// CreateInfoTableFromDataShape(dataShapeName:STRING, infoTableName:STRING("")):INFOTABLE

var assets = Resources['InfoTableFunctions'].CreateInfoTableFromDataShape(params);

var connection;

for each(connection in connections.rows) {

  var data = new Object();

  data.to = connection.to;

  data.from = connection.from;

  data.connectionType = connection.connectionType;

  var thing = Things[connection.to];

  

  var alert = MediaEntities["YellowAlert"].GetImage();

    data.description = thing.description + " " + alert; //appending alert icon with description

    assets.AddRow(data);

}

var result = MediaEntities["YellowAlert"].GetImage();

----

am unable to append image with text. I have tried keeping description type as text,blob,string in datashape.

am getting error as "[context: com.thingworx.webservices.context.HttpExecutionContext@2ea80460][message: Execution error in service script [FlowserveNetworkServices testImage] : Unable To Convert From [B to INFOTABLE]"

1 ACCEPTED SOLUTION

Accepted Solutions
posipova
20-Turquoise
(To:nbhagtani)

You could try HTML, I know it worked for a text + image for a grid cell (from an infotable);

View solution in original post

7 REPLIES 7
posipova
20-Turquoise
(To:nbhagtani)

You cannot add an image to a description, description has to be a string type. What is your use case?

Is there any other type i can keep which will accept String and Image?

I have to display description (string + image) on tree label. Image will be dynamic attached to some description and that description need to be displayed on tree.

posipova
20-Turquoise
(To:nbhagtani)

You could try HTML, I know it worked for a text + image for a grid cell (from an infotable);

So by keeping HTML as base type of one of my infotable fields.. it is possible to do that?

Thanks.. am able to append image to text in infotable.

PaiChung
22-Sapphire I
(To:nbhagtani)

I would use an infotable so one column carries the text the other the image.

If you are using this in a mashup, you can use state based formatting or use a composite of a value display with image display

I have kept description and image in different column in infotable. But i don't know how to display text+image on tree(text and image will change on logic).

Yes i have to show data in mashup and i have tried using state based formatting for tree but i am able to display icon then text and i need text then icon.

Top Tags