Menu

Portal - get FunctionalCI in Ticket Creation

Nico
2020-07-02
2020-12-18
  • Nico

    Nico - 2020-07-02

    Hi,
    I wrote an extension to customize the Portal. I created a brick to show the CIs owned by the logged in user:

          <bricks>
            <brick id="NM_cis" xsi:type="Combodo\iTop\Portal\Brick\BrowseBrick" _delta="define">
              <active>true</active>
              <rank>
                <default>70</default>
              </rank>
              <title>
                <default>My own CIs</default>
              </title>
              <levels>
                <level id="10">
                  <oql><![CDATA[
                    SELECT FunctionalCI AS fci
                    JOIN lnkContactToFunctionalCI AS lnk ON lnk.functionalci_id = fci.id
                    WHERE lnk.contact_id = :current_contact->id
                    ]]>
                  </oql>
                  <fields>
                    <field id="org_id"></field>
                  </fields>
                  <actions>
                    <action id="view" xsi:type="view">
                      <rank>1</rank>
                    </action>
                    <action id="create_from_this" xsi:type="create_from_this">
                      <class>UserRequest</class>
                      <icon_class>fc fc-new-request fc-1-6x fc-flip-horizontal</icon_class>
                      <rank>2</rank>-->
                      <rules>
                        <rule id="contact-to-userrequest"/>
                        <rule id="go-to-open-request-on-submit"/>
                      </rules>
                    </action>
                  </actions>
                  ...
    

    I added an action to create a UserRequest out of the CI (even with prefilling some fields).
    Now I am searching for a way to add the CI to the UserRequest.
    At the moment the Ticket is created but without any relationship to the CI.
    I have not found any Attribute or Placeholder to add the CI to the Request yet.

    It would be great if someone could give me a hint how to get the CI's name into the UserRequest (or the functionalcis_list ideally).

    Many thanks in advance,
    Nico

     
  • Nico

    Nico - 2020-07-10

    Hi Pierre,
    thanks for your reply.
    I'm not sure if we mean the same thing.
    For example: A user has 3 (or more) CIs that he can see in his portal (using the new extension mentioned above). Now he has a problem with one of his CIs and chooses it in the potal to open a request.
    The request will be opened but without any relationship to the CI.
    If I use the automatic-object-creation extension, it could be triggered on opening a request, but how does it know about the CI that the user had choosed in his portal? In addition it should only be triggered if used in conjunction with the "my own CIs" extension in the portal.
    Thanks again for your time.
    Best regards,
    Nico

     
  • Pierre Goiffon

    Pierre Goiffon - 2020-07-13

    Hello,
    This extension allows to create an action, in your use case it would be create a new UserRequest from a CI instance. Take a look at the documentation, give the extension a try, you will see quickly how it works :)

     
  • Nico

    Nico - 2020-07-13

    Hi,
    sorry, I dont get it.
    I already used the extension to automatically create Workorders if a UserRequest is raised or to add Documents on a newly created CI/PC.
    But I don't see the relationship on how to create a rule that adds the users CI to the UserRequest if he creates a new UserRequest out of the list of his CIs, in the portal.
    I dont want to create a new or another object when raising a UserRequest.
    I only want to add the name of the selected CI or link it directly when the request is opened (to the functionalcis_list).
    This is really frustrating since I already realised a lot in customizing iTop.
    I hope you could give me another hint.
    Many thanks in advance,
    best regards,
    Nico

     
  • Pierre Goiffon

    Pierre Goiffon - 2020-07-16

    Hello,

    Not sure to understand either ? I guessed that the user opens up in the user portal a list of CI, and needs to open a new UserRequest from one of this CI : in this case he could just opens the CI and use an action button that will trigger the Configurator for automatic object creation extension rule, that will create a new UserRequest with the CI attached.

    You might explain one or more use cases so that we can have a better idea of what you want to do ?

     
  • Nico

    Nico - 2020-07-16

    Hi Pierre,
    that's exactly what I try. I already have a rule for creating a UserRequest out of a CI. It is shown in the menu "Other Action" in the Backend but not when I open the CI in the Portal (as configured shown in my 1st Post).
    In the Portal I only got the Burger Menu next to the CI with 2 actions: "Details" and "New User Reqest", but that "New User Request" belongs to the --action id="create_from_this"-- declaration.
    How can I get the Menu from the automatic object creation extension rule visible here?
    Thanks again so much for your time,
    best regards,
    Nico

     
  • Pierre Goiffon

    Pierre Goiffon - 2020-07-17

    Hello,

    All my apologies the Configurator for automatic object creation extension doesn't provide anything for the use rportal indeed, it is limited to the admin console.

    For the portal, you could try to use action rules ?
    The syntax is similar to the one used in the extension.

     
  • Nico

    Nico - 2020-07-17

    Hi Pierre,
    ok, I already did some experiments with the action rules. But I dont know how to get any ID from the viewed CI.
    I only found out to have access to the username of the current logged in user and that origin is "portal".
    But I can't find any relationship between the called/viewed functionalCI and the UserRequest opened by "create-from-this".
    I succeeded in setting attributes (vie PrefillCreationForm function) that are shown in the creation form (service, service subcat, impact, urgency, title and description) but don't know how to get the functional_ci ID from the current viewed CI and set it in the creation form.
    Have a nice weekend,
    best regards,
    Nico

     
  • Pierre Goiffon

    Pierre Goiffon - 2020-07-20

    Check the action_rules that are present in the default datamodel. You'll find some in datamodels\2.x\itop-tickets\datamodel.itop-tickets.xml

     
  • Nico

    Nico - 2020-07-20

    Hi Pierre,
    i already had a look at that file. From there I got the "create_from_this" action.
    Now I added a field to the creation form to add the functional-ci:

                <form id="UserRequest_create" _delta="define">
                  <class>UserRequest</class>
                  <fields>
                    <field id="service_id"></field>
                    <field id="servicesubcategory_id"></field>
                    <field id="impact"/>
                    <field id="urgency"/>
                    <field id="title"/>
                    <field id="description"/>
                    <field id="functionalcis_list"/>
                  </fields>
                </form>
    

    I can see the functionalcis_list and manually select a CI owned by the portal user.
    To automatically add it I created this action rule:

        <action_rule id="NM_set-for-own-ci" _altered_in="hkt-portal-customization">
            <source_oql><![CDATA[SELECT FunctionalCI AS fci WHERE id = :this->id]]></source_oql>
          <presets>
            <preset id="1">add_to_list(id,functionalcis_list)</preset>
          </presets>
        </action_rule>
    

    But when I select "create request" in the portal I get this error:
    Missing query argument: expecting = this->id, available = {0=>current_contact_id; 1=>current_user->object(); 2=>current_contact->object()}

    If I set an id in the OQL Query the CI is added to the list. But I don't know how to get the ID automatically.

     
  • Pierre Goiffon

    Pierre Goiffon - 2020-07-22

    Hello,
    Try using source_class instead of source_oql ?
    This is how it is done in the servicesubcategory-to-userrequest action rule (see https://github.com/Combodo/iTop/blob/develop/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml#L1468)

     
    • Nico

      Nico - 2020-07-22

      Hi Pierre,
      I also tried that already:

        <action_rules>
          <action_rule id="NM_set-for-own-ci" _delta="define">
            <source_class>FunctionalCI</source_class>
            <presets>
              <preset id="1">copy(id, functionalcis_list)</preset>
            </presets>
          </action_rule>
        </action_rules>
      

      But I get this error message:
      Some action rules were not executed(destination object: UserRequest[-1]): NM_set-for-own-ci = Portal query was stopped: action_rule 'NM_set-for-own-ci' searches for 'FunctionalCI' without any condition is forbidden

       
      • Pierre Goiffon

        Pierre Goiffon - 2020-07-22

        Ok
        You're executing this from a browse brick right ?
        You already paste some XML in the thread, but to sum up can you upload the complete XML file to reproduce this on a standard iTop community version ?
        @glajarige might be able to help with this :)

         
        • Nico

          Nico - 2020-08-19

          Hi Pierre,
          I found out that changing this two things makes the rule working for CIs of type PC:
          1) changing source_class from "FunctionalCI" to "PC"
          2) changing preset id 1 from "copy(id, functionalcis_list)" to "add_to_list(id, functionalcis_list)"

          But, in the Portal different types of FunctionalCIs are shown, not only PC. Maybe some CIs of type Peripheral, too.
          If I try to open a UserRequest on this I of course get an error because the rule has its source in class PC, not Peripheral.
          So the best would be setting the source_class in the rule to "FunctionalCI" but that throws an error too.

          Maybe this helps to find a solution on opening UserRequests out of a CI with the specific CI automatically attached to the UR.
          Thanks,
          best regards,
          Nico

           
  • Nico

    Nico - 2020-07-22

    Hi,
    yes, I use a browse brick.
    Attached you can find the complete XML file.
    Many thanks for your time.

     
  • Nico

    Nico - 2020-08-04

    Hi,
    do you have any update for this case?
    It would be really helpful.
    Thanks,
    best regards,
    Nico

     
    • barakbar

      barakbar - 2020-12-18

      can these functionalci be mandatory? how?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.