GSD-RestApi Query event macro


This is a complete list of parameters that event macro must have in order to be properly executed when query of type "macro" takes place.

Parameter Type Description
&res: HJSON IN-OUT JSON Handle with returned error message, if any error occurs
class: STRING IN Class name (request query parameter)
&os: ObjectSet IN If request contains one of these fields: queryString, query or oids, the result of the query is stored to this set. Otherwise it remains unconstructed
&resSet: ObjectSet OUT Filtered objects are stored in this set. If there are no results, it is constructed and empty
&query: HJSON IN JSON Handle with query
&ok: BOOL OUT False when something went wrong, error info will be added to 'res HJSON'

Example declaration:

1
2
INT ExampleQueryEvent( HJSON &res, STRING class, DBOBJECTSET &os, DBOBJECTSET &resSet, HJSON &query, BOOL &ok )
RETURN( 1 )

Example usage:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
INT ExampleQueryEvent( HJSON &res, STRING class, DBOBJECTSET &os, DBOBJECTSET &resSet, HJSON &query, BOOL &ok )
    AdresseAllSet addressAS;
    Vorgang incident;
    STRING queryString;
    HJSON queryStringJson, oidJson;

    queryStringJson = query.GetMember( "queryString" );
    oidJson = query.GetMember( "oid" );

    IF( queryStringJson != NULL )
        resSet.Construct( "Adresse" );
        IF( addressAS.Query( queryStringJson.GetString(), resSet ) )
            ok = TRUE;
        ELSE
            res.xRestApi_Error_Error_QueryMacroError( "ExampleQueryEvent" );
        ENDIF
    ELSEIF( oidJson != NULL )
        IF( ok = xRestApi_CheckObjectAccessFromEx( oidJson.GetString(), res, incident ) )
            resSet.Construct( "Vorgang" );
            IF( !resSet.AddSet( incident.Untervorgaenge ) )
                ok = FALSE;
                res.xRestApi_Error_Error_AddToSet( "" );
            ENDIF
        ENIDF
    ENDIF

RETURN( 1 )