Skip to main content
Solved

Display a value from GI Using Customisation and PXGenericInqGrph

  • February 10, 2025
  • 5 replies
  • 67 views

Forum|alt.badge.img

Im trying to import 1 decimal value (a quantity of a kit at a particular location) from a GI table that has parameters. I dont know how to convert from the result to a single value? The below code doesnt work.

 

 

 Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("SiteID", row.SiteID.ToString());
                parameters.Add("KitID", row.InventoryID.ToString());
                PXGenericInqGrph gi = PXGenericInqGrph.CreateInstance("KitBuild3", "KitBuild3", parameters);
                PXResultset<GenericResult> results = gi.Results.Select();
                GenericResult result = results.FirstOrDefault();



                //var kitQtyList = results?.Cast<GenericResult>()?.ToList()?.Select(r => r.Values["KitQty"])?.ToList();

                 decimal? kitQty = Convert.ToDecimal(result.Values["KitQty"]);

 

Best answer by Dantheman88988

Use PXProjection, does not work to reference GI’s from code (that reference other GI’s)

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+1
  • Jr Varsity I
  • 24 replies
  • February 10, 2025

Hi, ​@Dantheman88988  
If I had Sales Order GI my steps would be following:
 

var gi = PXGenericInqGrph.CreateInstance("SO3010PL");
var res = gi.Results.Select();
GenericResult result = res.FirstOrDefault();
result.Values.TryGetValue(nameof(SOOrder), out var soOrder0);
SOOrder soOrder = soOrder0 as SOOrder;
decimal? orderQty = soOrder.OrderQty;

Check in which table your field id defined. And be aware that first parameter of TryGetValue() method is a gi alias 
 

 


Forum|alt.badge.img
  • Jr Varsity I
  • 62 replies
  • February 10, 2025

Hi @Dantheman88988,

Here's the corrected code to extract a decimal value from your Generic Inquiry,

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("SiteID", row.SiteID.ToString());
parameters.Add("KitID", row.InventoryID.ToString());

PXGenericInqGrph gi = PXGenericInqGrph.CreateInstance("KitBuild3", "KitBuild3", parameters);
PXResultset<GenericResult> results = gi.Results.Select();

decimal? kitQty = null;
if (results?.Any() == true)
{
    var result = results.FirstOrDefault();
    if (result?.Values?.ContainsKey("KitQty") == true)
    {
        var value = result.Values["KitQty"];
        kitQty = value != null ? Convert.ToDecimal(value) : 0m;
    }
}

The key is proper null checking and safe conversion. This handles cases where the GI returns no results or the KitQty field is empty.

Hope this helps


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 31 replies
  • February 10, 2025

thanks very much though it doesnt compile?

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 31 replies
  • February 10, 2025

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 31 replies
  • Answer
  • February 26, 2025

Use PXProjection, does not work to reference GI’s from code (that reference other GI’s)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings