This is a public Forum  publicRSS

Topic

    Pramod Vasudeva Murthy
    Set Incident Product by nameAnswered
    Topic posted February 10, 2018 by Pramod Vasudeva MurthyElite 
    78 Views, 7 Comments
    Title:
    Set Incident Product by name
    Content:

    Has anyone tried setting incident.Product by name? Is it even possible? I searched in docs and couldn't find any.

    Please let me know.

    TIA,

    ~VIP

    Version:
    17D

    Best Answer

    Suresh Thirukoti

    Pramod - Will this work...

    1.     $incident->Product =  RNCPHP\ServiceProduct::first("LookupName='{Name of the product}'");
    2.  

    Answer

     

    • Sebastiaan

      Hi Pramod.

      Do you mean assigning a product (incidents.prod_id) based on something in the incident (thread content, subject, mail headers)?
      I don't see product available in the business rules (only category). Maybe if you have prod and cat linked (or certain categories, invisible), then you could assign the category and it would receive the linked product?

      Say an invisible cat A that is linked to prod A and assign cat A through a business rule (not tested myself)

       

    • Pramod Vasudeva Murthy

      Sebastiaan,

      My question is we can set custom fields by name like this:

      $incident->CustomFields->c->incident_type = new RNCPHP\NamedIDLabel();
      $incident->CustomFields->c->incident_type->LookupName = "Lead";
       
      Could we do the same for incident.Product like this:
       
      $incident->Product = RNCPHP\ServiceProduct::fetch("<name>"):
       
      ~VIP
    • Sebastiaan

      Ah, that I don't know.

    • Suresh Thirukoti

      Pramod - Will this work...

      1.     $incident->Product =  RNCPHP\ServiceProduct::first("LookupName='{Name of the product}'");
      2.  
    • Pramod Vasudeva Murthy

      Wow, great share yes

      Works like a charm laugh

      ~VIP

    • Suresh Thirukoti

      Glad that it worked yes ..I just guessed by looking into the documentation...as I don't have instance to check

      ~Suresh

    • Pramod Vasudeva Murthy

      I tested it, works fine. Thanks for sharing.

      ~VIP