Announcement

Collapse
No announcement yet.

Workflow WebHook/JSON API code not running

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ids
    replied
    Wondering if I ran into a bug regarding this environment?

    Scott

    Leave a comment:


  • ids
    replied
    OK, this is strange. Hopefully, I can explain what I'm seeing.

    This code isn't executing:

    Code:
    <MvASSIGN NAME = "l.note" VALUE = "">
    <MvASSIGN NAME = "l.note:user_id" VALUE = "{ 0 }">
    <MvASSIGN NAME = "l.note:order_id" VALUE = "{ l.order_id }">
    <MvASSIGN NAME = "l.note:cust_id" VALUE = "{ 0 }">
    <MvASSIGN NAME = "l.note:notetext" VALUE = "{ l.notetext }">
    
    <MvIF EXPR = "{ NOT [ g.Module_Library_DB ].Note_Insert( l.note ) }">
       <MvASSIGN NAME = "l.notetext" VALUE = "{ l.notetext $ '| Failed|' }">
       <MvASSIGN NAME = "g.FilenameReturn" VALUE = "{ file_append(g.FileName, 'data', l.notetext) }">
       <MvFUNCTIONRETURN VALUE = 0>
    </MvIF>
    So, I returned to the Provide XML and added the required tags. This also didn't work. I looked at the tag recorded in PRV_inline.xml -- Store Code value is empty. The store code variables aren't populated. I tried, g.Store_Code, g.Store:Code, l.settings:store:code. All are not populated.

    Finally, I hardcoded my store code to a variable and used that in the XML string. Bingo. Both notes are added to the order.

    This doesn't seem to make sense to me. Note_Insert doesn't appear to require the store code. If it matters, I have the XML string executing before the Note_Insert function.

    I am trying to sift through a dump of Miva_getvarlist, but, it looks like there are many typical global vars that aren't populated with a value.

    Scott



    Leave a comment:


  • ids
    replied
    I'll give that a try (again :) ).

    Thanks.

    Leave a comment:


  • dcarver
    replied
    You need to wrap your XML code in a <Provision> tag and a <Store code="xxx"> tag for that function to work. To be honest, I wouldn't import XML like that. You're already a module, you could just call the Note_Insert function yourself.

    Leave a comment:


  • ids
    replied
    Thank Yu.

    That part make me happy, that the code looks like it should run.

    So, I retyped the URL in the web hook entry. It ran. But not all of it. The PRV_Action_ProvisionStringData function didn't appear to run. However, the addnote_XML did end up in a file, "PRV_inline.xml." Why wouldn't it have completed?

    Scott

    Leave a comment:


  • dcarver
    replied
    Everything looks fine. You could hit that URL yourself and start debugging it.

    Leave a comment:


  • ids
    replied
    I have another action (Add Note) which runs so I know it triggered.
    Only thing in the URL that has changed is the &Module_Function=test_it. Maybe I have a typo?

    I can't find any real info on the session type. Anything to that?

    Scott

    Leave a comment:


  • dcarver
    replied
    What URL did you define in the webhook? I'd imagine that is wrong or the workflow task is not being triggered.

    Leave a comment:


  • ids
    started a topic Workflow WebHook/JSON API code not running

    Workflow WebHook/JSON API code not running

    What I am missing? Seems like something simple. I had this concept working and now for some reason, it isn't, even with simple functions like these.

    The WebHook calls the module and then the function:

    Code:
    <MvELSEIF EXPR = "{ g.Module_Function EQ 'test_it' }">
       <MvFUNCTIONRETURN VALUE = "{ test_it( l.module ) }">
    I am not seeing the file get created nor the Note added to the order.

    Code:
    <MvFUNCTION NAME = "test_it" PARAMETERS="module var" STANDARDOUTPUTLEVEL = "html,text,compresswhitespace">
    
    <MvASSIGN NAME = "l.order_id" VALUE = "{ s.json_data:id }">
    
    <MvASSIGN NAME = "g.FileName" VALUE = "{ 'mylogfile.txt' }">
    <MvIF EXPR = "{ NOT fexists(g.FileName) }">
       <MvASSIGN NAME = "g.FilenameReturn" VALUE = "{ file_create(g.FileName, 'data', l.notetext ) }">
    <MvELSE>
       <MvASSIGN NAME = "l.notetext" VALUE = "{ g.Module_Function $ '|' $ l.order_id $ '|Overwrite|' }">
       <MvASSIGN NAME = "g.FilenameReturn" VALUE = "{ file_overwrite(g.FileName, 'data', l.notetext ) }">
    </MvIf>
    
    <MvCAPTURE VARIABLE = "l.addnote_XML" STANDARDOUTPUTLEVEL = "text, compresswhitespace">
       <MvEVAL EXPR = "{ '
          <Note_Add order="' $ l.order_id $ '">' $ l.notetext $ '</Note_Add>'
       }">
    </MvCAPTURE>
    <MvASSIGN NAME = "l.settings:provision:xml" VALUE = "{ trim(l.addnote_XML) }">
    <MvDO FILE = "{ g.Module_Feature_PRV_AD }" NAME = "l.settings:provision:result" VALUE = "{ PRV_Action_ProvisionStringData(l.settings:provisio n:xml) }">
    
    </MvFUNCTION>
Working...
X