Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Is there a possibility to create a stream programmatically?
According to this thread, I can duplicate a 'prototype' stream, but I have another requirement. I need to create a new stream an I need to choose the data shape of the stream while creating the stream.
Is this possible?
Solved! Go to Solution.
Hi @skef,
It's surely available:
var name = "YourStreamName"; Resources["EntityServices"].CreateThing({
name: name,
description: undefined,
thingTemplateName: "Stream", // this makes a Thing -> Stream
tags: undefined
}); // unfortunately, when doing this, we ends up with a new entity with no DataShape and PersistenceProvider
// so we need to set them manually
Things[name].EnableThing(); Things[name].RestartThing(); Things[name].SetDataShape({ name: "DataShapeWithPrimaryKey" });
// necessary to enable again Things[name].EnableThing(); Things[name].RestartThing();
// setting a default one Things[name].SetPersistenceProvider({ name: "ThingworxPersistenceProvider" }); Things[name].EnableThing(); Things[name].RestartThing();
For me, working on ThingWorx 8.3 - it's working fine, I can add records later.
Hope it helps.
BR,
JK.
Hi @skef,
It's surely available:
var name = "YourStreamName"; Resources["EntityServices"].CreateThing({
name: name,
description: undefined,
thingTemplateName: "Stream", // this makes a Thing -> Stream
tags: undefined
}); // unfortunately, when doing this, we ends up with a new entity with no DataShape and PersistenceProvider
// so we need to set them manually
Things[name].EnableThing(); Things[name].RestartThing(); Things[name].SetDataShape({ name: "DataShapeWithPrimaryKey" });
// necessary to enable again Things[name].EnableThing(); Things[name].RestartThing();
// setting a default one Things[name].SetPersistenceProvider({ name: "ThingworxPersistenceProvider" }); Things[name].EnableThing(); Things[name].RestartThing();
For me, working on ThingWorx 8.3 - it's working fine, I can add records later.
Hope it helps.
BR,
JK.