OQL Dataset Query in Microflow

0
I’ve created an OQL Query that returns the expected data in a report grid (so I know it works). However I wasn’t able to pass a parameter to the OQL query – it passes the $parameterObject but I cannot reference the object attribute. e.g. $parameterObject.attribute Q1) Does anyone know how to do this? Q2) My main issue is that I want to return the OQL into a list view or datagrid, I followed the steps here https://docs.mendix.com/howto/extensibility/howto-datastorage-api 4.Retrieving Objects Using OQL Specified in a Dataset I have no errors in my microflow but it gives a simple error at runtime ‘An error occurred while executing microflow data source for widget NCM.Landholder_home.listView1:  Error: An error occurred while executing microflow data source for widget NCM.Landholder_home.listView1:      at http://localhost:8080/mxclientsystem/mxui/mxui.js?637497825321317361:73:171397     at http://localhost:8080/mxclientsystem/mxui/mxui.js?637497825321317361:73:171521’   Any ideas? I’m using Mendix 9.2    
asked
15 answers
0

Hi Quinton,

What you can do is before you call the Retrieve OQL Dataset is to get the GUID of the Land_Holder object using the Java action getGUID from the Community Commons module. 

The use that in your query as follows: WHERE NCM.Land_Holder.ID = $LandHolderGUID.

answered
0

Hi Quinton,

Can you specify the OQL query that you want to create?

Cheers,

Jeffrey

answered
0

Hi Jeffrey,

 

The OQL query returns data as I can see it in a report widget, however if I add the parameter (NCM.Land_Holder.SBI = $LandHolder.SBI)  it errors.

This is the first issue.

Any ideas on the second issue where the Microflow fails?

answered
0

This just gives a type mismatch from string to object

If I edit the Parameter I only have the option of Object / Boolean etc. I can’t access the attribute here…

 

answered
0

It’s looking for an attribute from the error message.

answered
0

Hi Quinton,

Regarding Q2, could you share the stack trace for the runtime error associated with the Microflow?

Another option that would allow you to further debug the issue, especially in this case since you are calling the Java Action “Retrieve Dataset OQL”, is to debug the java action using eclipse following the steps provided in the following Mendix Doc:
https://docs.mendix.com/howto/monitoring-troubleshooting/debug-java-actions#1-introduction

If you are able to get the stack trace associated with the microflow error, could you please share it?

 

 

answered
0

HI Quinton,

Looking at the stack trace I noticed that is complaining about something not being implemented:

 

Any possibilities that a step could have been missed while following this document:

https://docs.mendix.com/howto/extensibility/howto-datastorage-api (https://docs.mendix.com/howto/extensibility/howto-datastorage-api

answered
0

I have followed the document to the letter, the only thing I’m questioning now is Core.createOQLTextGetRequestFromDataSet method described below. Is this something I need to import or is it already a core component of Mendix?

answered
0

This is now resolved - I was missing that I had to edit the .java and add the code as shown in the screenshot. Newbie error and big thanks to Mendix support. If anyone else is struggling then use the mendix runtime library to find the correct import modules that relate to the code functions.

answered
0

not sure that i’ve set this up correctly as the Java compiled at runtime shows two items (item and __item):

import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;

public class getGUID extends CustomJavaAction<java.lang.Long>
{
    private IMendixObject __item;
    private ncm.proxies.Land_Holder item;

    public getGUID(IContext context, IMendixObject item)
    {
        super(context);
        this.__item = item;
    }

    @java.lang.Override
    public java.lang.Long executeAction() throws Exception
    {
        this.item = __item == null ? null : ncm.proxies.Land_Holder.initialize(getContext(), __item);

        // BEGIN USER CODE
        return ORM.getGUID(__item);
        // END USER CODE
    }

    /**
     * Returns a string representation of this action
     */
    @java.lang.Override
    public java.lang.String toString()
    {
        return "getGUID";
    }

    // BEGIN EXTRA CODE
    // END EXTRA CODE
}
 

 

answered
0

Here is the Microflow – passing the parameter of the LandHolder context

 

answered
0

Here is the Microflow view with the parameter of the LandHolder object context passed – can’t see why it has the security issue?

Any ideas?

answered
0

Here is the Microflow – any ideas why the security is an issue. I’ve checked the Community Commons security and there is nothing obvious there?

 

Any ideas?

 

GetGUID

answered
0

Think the error is due to the matching of the types String to Long (returned from the getGUID)

 

 

SELECT 
    NCM.Land_Parcels/Parcel_Name                 as OB_Parcel_Name,
    NCM.Land_Parcels/ParcelID                as OB_ParcelID,
    NCM.Land_Parcels/Area_ha                as OB_Area_ha,
    NCM.Parcel_Cover/LC_Description            as OB_Land_Cover,
    NCM.Parcel_Cover/LC_Land_cover_class_code        as OB_LC_class_code,
    NCM.Opportunities/Opportunity_name             as OB_Opportunity_Name
from     NCM.Land_Parcels,
    NCM.Parcel_Cover,
    NCM.Opportunities,
    NCM.Land_Holder
WHERE NCM.Land_Parcels.sbi = NCM.Land_Holder.SBI
and   cast(NCM.Land_Holder.SBI as Long) = $LandHolderGUID 
and     NCM.Parcel_Cover.LC_SBI = NCM.Land_Holder.SBI
and     NCM.Parcel_Cover.LC_Parcel_id = NCM.Land_Parcels.ParcelID
and     NCM.Land_Parcels.Area_ha > NCM.Opportunities.Min_acre
and     NCM.Opportunities.Criteria_plant_trees = NCM.Land_Parcels.Objective_plant_trees
 

answered
0

I’ve created the getGUID java Action (Community Commons) in a microflow and the next step runs the OQL query but it’s not filtering the OQL query by the GUID. Any ideas?

 

 

 

 

answered