Hi Team,
I'm using an Interactive Automation Script component in my LCA, which includes DateTime fields defined in the script (attached source code below). I want to pass the selected values from these DateTime fields to GQI as input.
Is it possible to send values from the Interactive Automation Script component to GQI as input?
public class Script
{
public UIResults UiResults;
public UserDefinedAppHelper userDefinedAppHelper;
public IEngine _engine;
public string startTime;
public string endTime;
/// <summary>
/// The script entry point.
/// </summary>
/// <param name="engine">Link with SLAutomation process.</param>
public void Run(IEngine engine)
{
// .ShowUI(); Don't remove this comment, this is needed for interactive automation.
try
{
_engine = engine;
engine.GenerateInformation("create datetime picker started");
Init();
DatetimePickerAlarms alarms = new DatetimePickerAlarms(engine,startTime,endTime);
engine.GenerateInformation("object created");
while (!alarms.Close)
{
UiResults = engine.ShowUI(alarms.uib);
}
}
catch (Exception e)
{
engine.ExitFail("Run|Something went wrong: " + e);
}
}
public void Init()
{
userDefinedAppHelper= new UserDefinedAppHelper(_engine);
startTime= userDefinedAppHelper.GetAppValue("Start Time");
endTime=userDefinedAppHelper.GetAppValue("End Time");
}
}
namespace AH_Create_DateTimepicker_For_Alarms_1
{
public class DatetimePickerAlarms
{
public bool Close = false;
public UIBuilder uib = new UIBuilder();
public UIBlockDefinition blockCalendarStart = new UIBlockDefinition();
public DatetimePickerAlarms(IEngine engine,string startDatetime,string endDatetime) : base()
{
//Label start datetime
engine.GenerateInformation("UIBlockDefinition started");
UIBlockDefinition blockLabelStart = new UIBlockDefinition();
blockLabelStart.Type = UIBlockType.StaticText;
blockLabelStart.Text = "Alarm History - Start DateTime";
blockLabelStart.Row = 1;
blockLabelStart.Column = 1;
uib.AppendBlock(blockLabelStart);
//Label end datetime
engine.GenerateInformation("UIBlockDefinition started");
UIBlockDefinition blockLabelEnd = new UIBlockDefinition();
blockLabelEnd.Type = UIBlockType.StaticText;
blockLabelEnd.Text = "Alarm History - End DateTime";
blockLabelEnd.Row = 2;
blockLabelEnd.Column = 1;
uib.AppendBlock(blockLabelEnd);
//start datetime
engine.GenerateInformation("UIBlockDefinition started");
blockCalendarStart.Type = UIBlockType.Calendar;
engine.GenerateInformation("startDatetime-"+ startDatetime);
DateTime parsedStart = DateTime.Parse(startDatetime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
TimeZoneInfo ukTimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
DateTime ukTime = TimeZoneInfo.ConvertTimeFromUtc(parsedStart, ukTimeZone);
blockCalendarStart.InitialValue = ukTime.ToString("dd/MM/yyyy HH:mm:ss");
blockCalendarStart.Row = 1;
blockCalendarStart.Column = 2;
uib.AppendBlock(blockCalendarStart);
//end datetime
UIBlockDefinition blockCalendarEnd = new UIBlockDefinition();
blockCalendarEnd.Type = UIBlockType.Calendar;
DateTime parsedEnd = DateTime.Parse(endDatetime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
TimeZoneInfo ukTimeZoneEnd = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
DateTime ukTimeEnd = TimeZoneInfo.ConvertTimeFromUtc(parsedEnd, ukTimeZoneEnd);
blockCalendarStart.InitialValue = ukTimeEnd.ToString("dd/MM/yyyy HH:mm:ss");
blockCalendarEnd.Row = 2;
blockCalendarEnd.Column = 2;
uib.AppendBlock(blockCalendarEnd);
//engine.GenerateInformation("UIBlockDefinition started");
UIBlockDefinition blockButton = new UIBlockDefinition();
blockButton.Type = UIBlockType.Button;
blockButton.Text = "Search";
blockButton.Row = 3;
blockButton.Column = 1;
uib.AppendBlock(blockButton);
}
}
}
Hi Hari,
I see you are using the Interactive Automation Script component. This component has an On Finish event that is triggered when the automation script finishes.
In this event, you can configure a Change Variable action that uses a link to the script output.
You can then use this variable in your query to pass the value.
To expose a value from the automation script, you can use:
engine.AddScriptOutput("xxx", stringValue);
where xxx
is the property you reference in the Link to box.
Small sidenote: this only works with text values.
If you have any questions, feel free to reach out.
Kind regards,
Robin

Hi Hari,
The action won't show up when no variables are available in the application. You can create one by going to the 'All available data' section, opening the variable dropdown and clicking the + icon. Make sure the type is Text and it is NOT read-only.
Then the action will be available
Hi Robin,
Thanks for the response, i'm unable to see Change Variable action on the OnFinish Event in the Interactive script component. The DM version currently used is 10.5.2.0. Please let me know if its because of the version.
Also, i'm trying to feed Start & End Datetime value from Interactive automation script component to GQI.