Skip to main content
1-Visitor
March 3, 2017
Solved

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

  • March 3, 2017
  • 7 replies
  • 3378 views

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]"

Best answer by posipova

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

7 replies

20-Turquoise
March 3, 2017

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

nbhagtani1-VisitorAuthor
1-Visitor
March 3, 2017

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.

posipova20-TurquoiseAnswer
20-Turquoise
March 3, 2017

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

22-Sapphire I
March 3, 2017

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

nbhagtani1-VisitorAuthor
1-Visitor
March 6, 2017

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.