12
Views
1
Comments
[Integration Studio] Is there a way to return entity based on data type?
Question

I'm wondering if there's a way to pass in the Data Type and return an Entity of that Data Type, like how JSON Deserialize allows you to pass in a Data Type for the function to convert the deserialized JSON into that object?


What I'm trying to do is set up an integration function call that can help me dynamically update a field based on the field name, as a string.


A lot of widgets like calendar / select2 require OnChange callbacks to process the data before assigning to a field.
The code to deserialize the date or the selected fields is usually the same - the only difference is which field I'm saving to.
Instead of having a separate callback actions that each hold the same assignment node... I was wondering if there's a cleaner way to do this, i.e. pass in the field name and have the callback action know to update that field?


Is there an easier way to handle my use case? Thanks!

Rank: #288

HI 

A similar issue has been discussed several times before. AFAIK, there is no existing function for this.

But you can create your own extension to achieve. Base source maybe likes below, you can improve.
 

public void MssGetAttributeByName(object ssObject, string ssAttributeName, out string ssValue)

{

ssValue = "";

// TODO: Write implementation for action

var property = type.GetProperty("ss" + ssAttributeName);

if (property == null)

{

GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "property Is null", "MODULENAME");

}

else

{

GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, property.GetValue(ssObject).ToString(), "MODULENAME");

ssValue = property.GetValue(ssObject).ToString();

}

}