Menu

prefilling form with the ar_token

Sergi
2020-06-19
2020-07-07
  • Sergi

    Sergi - 2020-06-19

    Hi all,
    I have noticed that when we go through the catalog to open a ticket the new "create ticket" form is prefilled using the values in the encoded64 ar_token in the url. Basically the ar_token to create a ticket looks like this decoded:
    {"rules":["contact-to-userrequest","servicesubcategory-to-userrequest","go-to-open-request-on-submit"],"sources":{"ServiceFamily":"XX","Service":"XX","ServiceSubcategory":"XX"}}

    So, I'm trying to prefill the User Satisfaction in the closing form encoding this: {"sources":{"User satisfaction":"3"}}
    in the url: MyDomain/iTop/pages/exec.php/object/apply-stimulus/ev_close/UserRequest/RequestNum?exec_module=itop-portal-base&exec_page=index.php&portal_id=itop-portal&ar_token=encodedValue

    But it's not working. Not sure if I'm doing somenthing wrong or if it's more complex than what it looks like :)

    Anybody have tried this?
    Thanks in advance!

     

    Last edit: Sergi 2020-06-19
  • Guillaume Lajarige

    Hello Sergi,

    What you are refering to is used to prefill an object (eg. User request) based on the one you clicked on (eg. Service). In your case, as you want to prefill a transition form, you should have a look at the "Form Prefill" feature that was introduced in iTop 2.4 which does just what you want :)

    Hope this helps,
    Guillaume

     
  • Sergi

    Sergi - 2020-06-19

    Hi Guillaume,
    Thanks for the quick answer!
    Our goal was to have 4 different links with the 4 different values of User Satisfaction, so on the resolve notification email we could add the 4 links using star images (amazon like feedback :P) or smiley/sad faces, that take you to the prefill form with your selectec feedback.
    I not sure it will be possible with the Form Prefill (I didn´t know about it and just had a quick look).
    Well, thanks a lot for your answer!!

     
  • Guillaume Lajarige

    Hello Sergi,

    Unfortunately there is no easy way to do this, but here is how you could proceed:

    • In the email notification, put links with a custom parameter in the URL (eg. &rate=5)
    • Then in the Form Prefill function, get this parameter through the $sRate = utils::ReadParam('rate') method
    • Then preset the value in the object with something like $this->Set('user_satisfaction', $sRate);

    Hope it helps,
    Guillaume

     
  • Sergi

    Sergi - 2020-07-07

    Hi Guillaume,
    I finally had time to try it and it worked :)
    Thanks a lot!!!!

     
    👍
    1
    ❤️
    1

Log in to post a comment.

MongoDB Logo MongoDB