Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
hello
I want to manage a list of devices with attributes (infotable) into a list of alert management (another infotables)
The list of alerts is working fine and is managed from a mashup (using AddOrUpdateDataTableProperties ).
This issue is with the list of devices attached to theses alerts which is generated by script.
Only some attributes are saved (boolean for example) but not all (the name of device for example).
To add a device into the list, I'm using device = new Object(), and after AddRow (device) to the list of devices attached to the alert.
I tried several method (Clone() for example) without succes.
The number of rows for the device list is well incremented but some attributes are not saved (I tested into a grid )
is there something specific for infotable into infotable or something special to do to update the primary infotable ?
Thanks for ideas
Regards
Solved! Go to Solution.
I solved the issue by cloning the 2 infotables before to modify them and using AddOrModifyInfotableEntries for the main infotable once modied. Otherwhile datas for the second infotable declared as a property of main infotable were lost once the service was exited.
Hi Pascal,
Can you please describe the datashapes of both infotables (column names and types). We need this to understand the relationship between them.
Thanks,
Hi validmir
Main Infotable :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Entities build="b47" majorVersion="7" minorVersion="4" modelPersistenceProviderPackage="PostgresPersistenceProviderPackage" revision="9" schemaVersion="941">
<DataShapes>
<DataShape baseDataShape="" description="" documentationContent="" homeMashup="" lastModifiedDate="2018-07-17T23:04:44.958+02:00" name="ListeOfAlertes" projectName="" tags="">
<Owner name="Administrator" type="User"/>
<avatar/>
<DesignTimePermissions>
<Create/>
<Read/>
<Update/>
<Delete/>
<Metadata/>
</DesignTimePermissions>
<RunTimePermissions/>
<VisibilityPermissions>
<Visibility/>
</VisibilityPermissions>
<ConfigurationTables/>
<FieldDefinitions>
<FieldDefinition baseType="STRING" description="" name="Domaine" ordinal="4"/>
<FieldDefinition baseType="STRING" description="" name="DomaineAAfficher" ordinal="5"/>
<FieldDefinition baseType="STRING" description="" name="Emails" ordinal="6"/>
<FieldDefinition baseType="BOOLEAN" description="" name="Humidite" ordinal="10"/>
<FieldDefinition aspect.defaultValue="80.0" aspect.units="%" baseType="NUMBER" description="" name="HumiditeMax" ordinal="12"/>
<FieldDefinition aspect.defaultValue="10.0" aspect.units="°C" baseType="NUMBER" description="" name="HumiditeMin" ordinal="11"/>
<FieldDefinition aspect.dataShape="ListOfDevicesAssociesAlerte" aspect.isStreamEntry="true" baseType="INFOTABLE" description="" name="ListeDevicesAssocies" ordinal="17"/>
<FieldDefinition baseType="BOOLEAN" description="" name="Luminosite" ordinal="13"/>
<FieldDefinition aspect.defaultValue="20000.0" aspect.units="lux" baseType="NUMBER" description="" name="LuminositeMax" ordinal="14"/>
<FieldDefinition baseType="BOOLEAN" description="" name="Mouvements" ordinal="15"/>
<FieldDefinition aspect.defaultValue="Not defined" aspect.isPrimaryKey="true" baseType="STRING" description="" name="Nom" ordinal="1"/>
<FieldDefinition baseType="BOOLEAN" description="" name="PositionVerticale" ordinal="16"/>
<FieldDefinition baseType="STRING" description="" name="Site" ordinal="2"/>
<FieldDefinition baseType="STRING" description="" name="SiteAAfficher" ordinal="3"/>
<FieldDefinition baseType="BOOLEAN" description="" name="Temperature" ordinal="7"/>
<FieldDefinition aspect.defaultValue="35.0" aspect.units="°C" baseType="NUMBER" description="" name="TemperatureMax" ordinal="9"/>
<FieldDefinition aspect.defaultValue="5.0" aspect.units="°C" baseType="NUMBER" description="" name="TemperatureMin" ordinal="8"/>
</FieldDefinitions>
</DataShape>
</DataShapes>
</Entities>
Infotable in this infotable
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Entities build="b47" majorVersion="7" minorVersion="4" modelPersistenceProviderPackage="PostgresPersistenceProviderPackage" revision="9" schemaVersion="941">
<DataShapes>
<DataShape baseDataShape="" description="listes des devices qui on déclanché une Alerte Associé à une alerte permet de ne pas répéter les alertes" documentationContent="" homeMashup="" lastModifiedDate="2018-07-17T07:36:20.487+02:00" name="ListOfDevicesAssociesAlerte" projectName="" tags="">
<Owner name="Administrator" type="User"/>
<avatar/>
<DesignTimePermissions>
<Create/>
<Read/>
<Update/>
<Delete/>
<Metadata/>
</DesignTimePermissions>
<RunTimePermissions>
<Permissions resourceName="*">
<PropertyRead>
<Principal isPermitted="true" name="System" type="User"/>
</PropertyRead>
<PropertyWrite>
<Principal isPermitted="true" name="System" type="User"/>
</PropertyWrite>
<ServiceInvoke>
<Principal isPermitted="true" name="System" type="User"/>
</ServiceInvoke>
<EventInvoke>
<Principal isPermitted="true" name="System" type="User"/>
</EventInvoke>
<EventSubscribe>
<Principal isPermitted="true" name="System" type="User"/>
</EventSubscribe>
</Permissions>
</RunTimePermissions>
<VisibilityPermissions>
<Visibility/>
</VisibilityPermissions>
<ConfigurationTables/>
<FieldDefinitions>
<FieldDefinition baseType="BOOLEAN" description="" name="HumiditeNotifie" ordinal="8"/>
<FieldDefinition baseType="BOOLEAN" description="" name="LuminositeNotifie" ordinal="8"/>
<FieldDefinition baseType="BOOLEAN" description="" name="MouvementsNotifie" ordinal="8"/>
<FieldDefinition aspect.isPrimaryKey="false" baseType="STRING" description="" name="Name" ordinal="2"/>
<FieldDefinition baseType="BOOLEAN" description="" name="TemperatureNotifie" ordinal="8"/>
<FieldDefinition aspect.isPrimaryKey="true" baseType="STRING" description="" name="UniqueId" ordinal="1"/>
<FieldDefinition baseType="BOOLEAN" description="" name="VerticalNotifie" ordinal="8"/>
</FieldDefinitions>
<ConfigurationChanges>
<ConfigurationChange changeAction="CREATE" changeReason="header : name : updated " timestamp="2018-07-17T07:36:20.486+02:00" user="Administrator"/>
</ConfigurationChanges>
</DataShape>
</DataShapes>
</Entities>
I created "UniqueId" as I though that using "Name" as primary key was the issue to AddRow (but I do not need as I'll need unique "Name")
some informations on the script and on the logs associated :
//Creation or clone of the infotable (property of "alerte" which is also Infotable)
if ( alerte.ListeDevicesAssocies == undefined ) {
var params = {
infoTableName : "InfoTable",
dataShapeName : "ListOfDevicesAssociesAlerte"
};
var clonedListeDevicesAssocies = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
}
else {
var params = {
t1: alerte.ListeDevicesAssocies /* INFOTABLE */
};
var clonedListeDevicesAssocies = Resources["InfoTableFunctions"].Clone(params);
}
//creation of the values (row) to be added :
var deviceAAssocier = DataShapes["ListOfDevicesAssociesAlerte"].CreateValues();
// update of some items as example
deviceAAssocier.Name = me.name;
deviceAAssocier.UniqueId = generateGUID();
//Add the row :
clonedListeDevicesAssocies.AddRow ( deviceAAssocier);
// Copy in initial Infotable
alerte.ListeDevicesAssocies = clonedListeDevicesAssocies;
----------------
Some logs :
clonedListeDevicesAssocies BEFORE ADD ROW
===>>>{"rows":[],"dataShape":{"fieldDefinitions":{"UniqueId":{"name":"UniqueId","aspects":{"isPrimaryKey":true},"description":"","baseType":"STRING","ordinal":1},"TemperatureNotifie":{"name":"TemperatureNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"VerticalNotifie":{"name":"VerticalNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"HumiditeNotifie":{"name":"HumiditeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"LuminositeNotifie":{"name":"LuminositeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"MouvementsNotifie":{"name":"MouvementsNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"Name":{"name":"Name","aspects":{"isPrimaryKey":false},"description":"","baseType":"STRING","ordinal":2}}}}
ROW TO ADD ====>>>>
deviceAAssocier ===>>>{"rows":[{"UniqueId":"e6b3c897-f477-4ad0-a4af-4f9bddd59aea","TemperatureNotifie":true,"Name":"M2WineTest"}],"dataShape":{"fieldDefinitions":{"UniqueId":{"name":"UniqueId","aspects":{"isPrimaryKey":true},"description":"","baseType":"STRING","ordinal":1},"TemperatureNotifie":{"name":"TemperatureNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"VerticalNotifie":{"name":"VerticalNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"HumiditeNotifie":{"name":"HumiditeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"LuminositeNotifie":{"name":"LuminositeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"MouvementsNotifie":{"name":"MouvementsNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"Name":{"name":"Name","aspects":{"isPrimaryKey":false},"description":"","baseType":"STRING","ordinal":2}}}}
clonedListeDevicesAssocies AFTER ADD ROW
clonedListeDevicesAssocies APRES ===>>>{"rows":[{}],"dataShape":{"fieldDefinitions":{"UniqueId":{"name":"UniqueId","aspects":{"isPrimaryKey":true},"description":"","baseType":"STRING","ordinal":1},"TemperatureNotifie":{"name":"TemperatureNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"VerticalNotifie":{"name":"VerticalNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"HumiditeNotifie":{"name":"HumiditeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"LuminositeNotifie":{"name":"LuminositeNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"MouvementsNotifie":{"name":"MouvementsNotifie","aspects":{},"description":"","baseType":"BOOLEAN","ordinal":8},"Name":{"name":"Name","aspects":{"isPrimaryKey":false},"description":"","baseType":"STRING","or
I solved the issue by cloning the 2 infotables before to modify them and using AddOrModifyInfotableEntries for the main infotable once modied. Otherwhile datas for the second infotable declared as a property of main infotable were lost once the service was exited.