Im returing a table of rows from GQI to LCA. Currently i have static column names. But I want to make it dynamic. I have fetched the necessary column names from DOM, but i can only access it in the method GetNextPage() as i want DM service to fetch the column names. Below is the code,
public GQIPage GetNextPage(GetNextPageInputArgs args)
{
var rows = new List<GQIRow>();
var serviceList = GetElements();
_logger.Information("SERVICE LIST -- " + serviceList.Count);
foreach (var service in serviceList)
{
var templateInstance = _domHelper.DomInstances.ReadAll().Where(x => x.GetSectionField<string>(
Em_Resourcemanagement.Sections.Protocol.Id,
Em_Resourcemanagement.Sections.Protocol.Workflow_Name) == service.Name && x.GetSectionField<string>(Em_Resourcemanagement.Sections.Serviceparams.Id,
Em_Resourcemanagement.Sections.Serviceparams.Is_Resource_Console) == "True");
foreach (var instance in templateInstance)
{
_resources=GetPidsFromDom(instance);
}
_logger.Information("ServiceName - " + service.Name);
var childInfos = service.Children.ToList();
//my other logics_logger.Information("ROWS Length -- " + rows.Count);
return new GQIPage(rows.ToArray());
}
public GQIColumn[] GetColumns()
{
var resourceColumns = _resources.Select(x => new GQIStringColumn(x.DisplayColName)).ToList();
resourceColumns.Insert(0, new GQIStringColumn("Service"));
resourceColumns.Insert(1, new GQIStringColumn("Element"));
return resourceColumns.ToArray();
}
Previously i have declared the column names in OnInit function itself. After changing my code like this im getting error in my LCA. based on the logs i can see GetNextPage is not reached. The method hierarchy is On init function, Argument processed, Get Columns - error is caught in Get columns function and _resources will be empty
I have added this code in get columns itself and now i could see the columns. Init was giving error as the input argument was not yet processed.
thanks for the suggestion
As mentioned in the comments on your question, the _resources should be fetched and set in the first lifecycle hook that has all the necessary information.
You're depending on both the callback (provided during OnInit) and the arguments (available in OnArgumentsProcessed). According to the lifecycle documentation, OnArgumentsProcessed is called after OnInit, meaning you will have all the required information starting from that point.
Docs: https://docs.dataminer.services/user-guide/Advanced_Modules/Dashboards_and_Low_Code_Apps/GQI/Extensions/Ad_hoc_data/Ad_hoc_Life_cycle.html?q=cycle
Since _resources is only initialized in the GetNextPage() step, it remains null during the GetColumns() step, which is called earlier. It might be possible to execute your logic in the OnInit step so that it’s ready for the GetColumns() step. Have you already considered this? If so, what issue did you encounter?