7 Replies Latest reply on Apr 25, 2019 4:32 AM by Misi Mladoniczky

    Pass field values to Menu Query object?

    Lonnie Murray
      Share:|

      In the C API, How do you pass field values to the menu definition object (ARCharMenuStruct)  for query menus with queries like ('Category' = $200000003$)?   I can't find instructions in the C API documentation itself.

       

      I see a series of left operands and right operands nested together but no clear place to detect and insert field values.

       

      I'm very familiar with the .Net API where the other field values are passed along with ExpandMenu. 

       

       

        • 1. Re: Pass field values to Menu Query object?
          Lonnie Murray

          I've tried inserting field values into the ARQualifier strut of the menu definition with no luck... Any thoughts out there on how to get ARExpandCharMenu to work with dynamic fields?  

           

          ARQualifierStruct *insertMenuValues(ARInternalId *fieldID, char *fieldval, ARQualifierStruct *MenuQual) {

          if (MenuQual) {

               if (MenuQual->operation == 4) {

                    ARInternalId tmpID = MenuQual->u.relOp->operandLeft.u.fieldId;

                    if (tmpID == fieldID) {

                         MenuQual->u.relOp->operandLeft.u.value.u.charVal = fieldval;

                    }

                    tmpID = MenuQual->u.relOp->operandRight.u.fieldId;

                    if (tmpID == fieldID) {

                         MenuQual->u.relOp->operandRight.u.value.u.charVal = fieldval;

                    }

               }

           

               ARQualifierStruct *subQual;

               if (MenuQual->operation > 1) {

                    if (MenuQual->operation < 10) {

                         subQual = MenuQual->u.andor.operandLeft;

                         insertMenuValues(fieldID, fieldval, subQual);

           

                         subQual = MenuQual->u.andor.operandRight;

                         insertMenuValues(fieldID, fieldval, subQual);

           

                    }

               }

                    return MenuQual;

               }

          }

          • 2. Re: Pass field values to Menu Query object?
            Lonnie Murray

            I'm now wondering if it might have something to do the with Server Side Menu option? 

             

            What does ARExpandSSMenu() do?  I can't find any documentation on it, or server side menus.   I do see that the ARCharMenuSSStruct does have a means to accept a fieldValueList object.

            • 3. Re: Pass field values to Menu Query object?
              Misi Mladoniczky

              Hi,

               

              I think you are on the right track in traversing the ARQualifierStruct to insert your value.

               

              Maybe you can use the ARDecodeARQualifierStruct() and AREncodeARQualifierStruct() and instead just replace the correct place in the string instead?

               

                      Best Regards - Misi, RRR AB, http://rrr.se

              • 4. Re: Pass field values to Menu Query object?
                Misi Mladoniczky

                Hi,

                 

                I am now looking more closely at your code, and it seems to be wrong.

                 

                What you should do is to find all ARFieldValueOrArithStruct with a tag of AR_FIELD_CURRENT and the fieldId = 200000003 (the number between the $-signs).

                 

                When you find it you must change the tag to AR_VALUE and then create then fill the value (ARValueStruct) with both the right dataType and u.charVal.

                 

                Please read the ar.h-file where I got all this information from.

                 

                        Best Regards - Misi, RRR AB, http://rrr.se

                1 of 1 people found this helpful
                • 5. Re: Pass field values to Menu Query object?
                  Lonnie Murray

                  Regarding the AREncodeARQualifierStruct(), I can't get it to do much.

                   

                     char **encodedQual;

                       qualStruct = menuDef.u.menuQuery.qualifier;

                       AREncodeARQualifierStruct(&c, &qualStruct, &encodedQual, &s);

                   

                  Returns nothing in encodedQual  even though there are most clearly qualifications.  Being a newbie and all with C, I'm sure there is something obvious I'm missing?

                  • 6. Re: Pass field values to Menu Query object?
                    Lonnie Murray

                    Here's the function that worked for me...  It'd be great if someone documented this so that it was available to other people.  I'd appreciate any suggestions for improvements.  Btw, "paste" doesn't work well on this forum. 

                     

                    InsertMenuValues.jpg

                     

                     

                    • 7. Re: Pass field values to Menu Query object?
                      Misi Mladoniczky

                      Looks pretty good to me.

                       

                      Might do a strdup(fieldval) to allow freeing of the structure at a later time.

                       

                      Another idea would be to supply a currentFieldValueList instead of just a single fieldID and fieldval that contains all the CURRENT data.

                       

                      And I did not check if the recursion got everything, but maybe it did ;-)

                       

                               Best Regards - Misi, RRR AB, http://rrr.se