Customer Portal

Get Involved. Join the Conversation.

Topic

    ilamukky
    create an Incident with a Product valueAnswered
    Topic posted June 25, 2015 by ilamukky Gold Medal: 3,500+ Points, last edited June 25, 2015 
    976 Views, 6 Comments
    Title:
    create an Incident with a Product value
    Content:

    Hello :)  can you give me a clarification about how to set a product when submitting an Incident? In standard ProductCategoryInput widget, I saw that the eventObject sent when validating the form is

       formEventObject.data.name = "Incident.Product"
       formEventObject.data.value = 8438  (I have the productID value from another widget)

    and then
       RightNow.Event.fire("evt_formFieldValidatePass", formEventObject);

    I tried to replicate this behaviour but without success.

    I tried also to pass the whole product hierarchy in an array, set the table etc...
       formEventObject.data.table = "Incident";
       formEventObject.data.value = [8025, 8076, 8438];
       formEventObject.data.dataType = "Product";
       formEventObject.data.level = 2;
    ...

    Are these field correctly set? am I forgetting something? Thanks very much for every explanation

    Version:
    Feb2015 CP3

    Best Comment

    ilamukky

    I resolved by extending the standard ProductCategoryInput widget, and firing an event from my widget to this extended one, to pass the product to be validated when it changes.

    In a custom method: this.data.js.productID = eventObject[0].data.productID;

    In onValidate method:   formEventObject.data.value = this.data.js.productID;

    Comment

     

    • Kesava Kumar

      Hi ilamukky,

      Can you give me clarification on which process you following for submitting incident

      Is this by extending standard widget or with your own custom widget?

      Thanks

      kesava

    • ilamukky

      Thanks Kesav



      In Ask a Question page, I have a <form> tag containing some FormInput widgets, a FormSubmit widget and a custom widget named "ProductSelected". I have productLabel, productID and product hierarchy, variables coming from autocomplete product textbox, or product cookie, or a serialnumber validation widget. The product Label is displayed in a textbox, and I would like to submit productID and hierarchy to the incident, when form is submitted, so that I can have them in "product" field of Incident object (like subject, etc).



      The problems are 2:



      1) How can I catch the formSubmit event?  In CP2, I had to subscribe "evt_formFieldValidateRequest" ; here in CP3, there is a this.parentForm().on('submit'... but if I write this statement I get an error (this problem is described here: https://cloudcustomerconnect.oracle.com/posts/1f46ab9018).

      As workaround, i created a extension of an input widget, that on Submit event fires an event to my widget, so I can make my submit logic (I hope there will be a better solution...).



      2) How can I send my data (product ID ) to Incident object? I tried to replicate the logic of ProductCategoryInput, as explained in the above post, but it doesn't work.



      Sorry for the confusion  -.-'

    • Anurag Mittal

      Ilamukky,

      You can use default_value attribute of ProductCategoryInput widget to do your job. Create a php variable and store product ID, then  create a div which is hidden by default and add ProductCategoryInput widget with default_value attribute (set it to phpvarible ) inside this div. Add this div inside your form.

      Do something like this:

          <div style="display:none">
              <?$phpVariable = "Comma-separated IDs of product ID ";?>
              <rn:widget  path="input/ProductCategoryInput" default_value="#rn:php:$phpVariable#" /> 
          </div>

      To learn about the attribute and how to set it 

      default_value

      • Name: Default Value
      • Type: STRING
      • Description: Comma-separated IDs (commas denoting hierarchy levels) of products or categories that should be populated by default
      • Default:

       

      #rn:php:PHP Code#

      The PHP code tag is used to execute PHP code in widget attributes. This can be a variable reference or a simple function call. Because of the nature of the tag, simple one-line PHP constructs should be used. This tag only applies when used in widget attributes. It will not get converted when used outside of a widget call, normal PHP code should be used outside of widget calls.

      Example
      Tag: <?$phpVariable = "Some Text";?>
              <rn:widget path="path/to/widget" label="#rn:php:$phpVariable#" /> 
      Returned Value: Label attribute on widget would become 'Some Text' 

       

      ~Anurag

       

    • ilamukky

      Perfect Anurag, thanks... I thought a similar thing, but I have the doubt that if another widget changes the value (it can be changed in the page) , the attribute is not updated. I will try and let you know. thanks!

      UPDATE: passing the value as attribute (reading it from cookie) works well, the value is submittted, but if this is modified it is not.... so I have to try another way.

    • ilamukky

      I resolved by extending the standard ProductCategoryInput widget, and firing an event from my widget to this extended one, to pass the product to be validated when it changes.

      In a custom method: this.data.js.productID = eventObject[0].data.productID;

      In onValidate method:   formEventObject.data.value = this.data.js.productID;

    • Ammar Aldaffaie

      Hi ilamukky,

      I'm trying to implement the same thing here but setting the product is not working for me, can you please post your code for the extended ProductCategoryInput widget please?