Hi,
I'm trying to add an item to an table through an context menu:
This is the context menu
<Param id="1399">
<Name>TieLines_ContextMenu</Name>
<Description>Context Menu Tielines</Description>
<Type>write</Type>
<Interprete>
<RawType>other</RawType>
<LengthType>next param</LengthType>
<Type>string</Type>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
</Display>
<Measurement>
<Type>discreet</Type>
<Discreets>
<Discreet options="table:singleselection" dependencyValues="1202?:[value:1202];1203?:[value:1203];1204?:[value:1204];1205?:[value:1205]">
<Display>Edit...</Display>
<Value>edit</Value>
</Discreet>
<Discreet dependencyValues="1202;1203;1204;1205;1206;1207?;1208?">
<Display>Add...</Display>
<Value>add</Value>
</Discreet>
<Discreet options="table:selection;confirm:The selected Tieline(s) will be deleted permanently.">
<Display>Delete selected row(s)</Display>
<Value>delete</Value>
</Discreet>
</Discreets>
</Measurement>
</Param>
and this is my code:
public void Run(IEngine engine)
{
Element vmatrix = engine.FindElement(engine.GetDummy("vmatrix").Name);
AddTieLine(engine, vmatrix, "4546d0b1-77cd-4070-86a2-485152b01d14", "17", "e21c2a9e-29d5-4edd-8697-c7a7e89a1d29", "1", "5");
}//1202;1203;1204;1205;1206;1207?;1208?
private static void AddTieLine(IEngine engine, Element ThisElement, string sourceGuid, string sourceId, string destinationGuid,string destinationId,string prio)
{
int ContextMenuParameterId = 1399;SetDataMinerInfoMessage DmInfoMessage = new SetDataMinerInfoMessage
{
DataMinerID = ThisElement.DmaId,
ElementID = ThisElement.ElementId,
Sa2 = new SA
{
Sa = new string[] {
Guid.NewGuid().ToString(),
"add",
sourceGuid,
destinationGuid,
sourceId,
destinationId,
prio
},
},Uia1 = new UIA
{
Uia = new uint[] {
(uint)ThisElement.DmaId,
(uint)ThisElement.ElementId,
(uint)ContextMenuParameterId,
},
},
What = 287,
};Engine.SLNet.SendSingleResponseMessage(DmInfoMessage);
}
to be clear:
1202 string
1203 string
1204 double
1205 double
1206 double
Error:
Script Failure (RBM-AS-RSTielineCrud): System.NullReferenceException: Object reference not set to an instance of an object.
at CManagedAutomation.RunWrapped(CManagedAutomation* , Int32 iCookie, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* pvarReturn, String scriptName)
at CManagedAutomation.Run(CManagedAutomation* , Int32 iCookie, Char* bstrScriptName, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* varEntryPoint, tagVARIANT* pvarReturn, tagVARIANT* pvarEntryPointResult) (CSharp; 0x80004005h): (see comment for more details)
Appearntly i should use some other call or change something but not shure what i should change.
Right, nothing to do with the context menu:
engine.GetDummy("vmatrix").Name -> engine.GetDummy("vmatrix").ElementName
and it works 😉