How can I retrieve the values of the params associated to the Input profile definition Instance?
The ProfileLoad script has an script param: ProfileInstance. This contains a Json with Node and In:
ProfileInstance {"Node":"89704d47-4ebf-4a8b-b10a-ebe0c40863fd","In":"e96cd576-ac3e-4e23-9fa7-f9d6300fd5ea"}
NodeProfileConfiguration nodeProfileConfiguration = new NodeProfileConfiguration(this.InputData.ProfileInstance);
var helper = new ProfileParameterEntryHelper(engine);
engine.GenerateInformation("** amount of interfaces " + nodeProfileConfiguration.Interfaces.Count());
When using this code the amount of interfaces is 0.
So how can I get the params of the Input Interface?
In our script, we load the script parameter like this:
ProfilesInstance = LoadScriptParameter<Dictionary<string, Guid>>(engine, ProfileInstanceParamName);
By using the "In" key, we get the profile instance:
InterfaceProfileInstance = profileHelper.GetProfileInstance(interfaceProfileInstanceGuid);
Then you can do something like this to get a specific parameter:
ProfileParameterEntry profileParameter = InterfaceProfileInstance .Values.SingleOrDefault(x => x.Parameter.Name == paramName);
Thank you Jarno. The below piece of code did the trick for me.
string domReference = string.Empty;
var interfaceProfileInstanceGuid = InputData.ProfileInstance[“In”];
var profileHelper = new ProfileHelper(Engine.SLNet.SendMessages);
FilterElement filter = ProfileInstanceExposers.ID.Equal(interfaceProfileInstanceGuid);
var interfaceProfileInstance = profileHelper.ProfileInstances.Read(filter).FirstOrDefault();
if (interfaceProfileInstance != null)
{
var domInputParam = interfaceProfileInstance.Values.FirstOrDefault(x => x.Parameter.Name == Constants.PD.Parameters.DomReference);
if(domInputParam!= null)
{
string value = domInputParam.Value.Type == ParameterValue.ValueType.Double ? Convert.ToString(domInputParam.Value.DoubleValue) : domInputParam.Value.StringValue;
domReference = value;
}
}
Hi Mieke,
The profile instance script parameter is a serialized dictionary of GUIDs that you then can use to retrieve data from the system.
Are you using the template "PA_ProfileLoadTemplate" script as a base for yours? Could you test with that one to see if you get the same result?
Note: the code examples are using the ProfileManagerHelper. In case you use the ProfileHelper – which is more recent and prefered – you can get the profile instance by doing this:
FilterElement filter = ProfileInstanceExposers.ID.Equal(guid);
interfaceProfileInstance = profileHelper.ProfileInstances.Read(filter).FirstOrDefault();