Gravatar for divyadevi.devara@gmail.com

Question by divya, Sep 9, 2015 2:31 PM

Coveo Attach to Case Functionality

Hi,

I have few questions on Coveo [Attach to Case] functionality.

In the new Coveo version, any content type(Ideas, Answers, Known Issues and Knowledge Articles) attached to case is stored in AtatchedResult Object. My question is how to get the content type of the result attached to a Case.

If we know the content type, is it possible to query from Coveo Object(Ideas, Articles, Answers etc) to get additional data of the result attached.

1 Reply
Gravatar for atheriault2@coveo.com

Answer by atheriault2, Sep 9, 2015 4:09 PM

Hi Divya,

The content type is not stored inside the AttachedResult object, but it's possible to query Coveo to get more info on those results. Inside the AttachedResult object there's a field called UriHash. You can use that value to uniquely identify document inside Coveo's index.

With that value, you can then build a query that looks like @sysurihash='IKaZ99H1YZjP1O1y' to get additional data on a specific document.

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 9, 2015 5:36 PM

Hi,

Thankyou for the information. I need to get the content data and use in a trigger. Can you tell me if there is any built-in API in salesforce for Coveo, so that I can invoke it to get Data Is there anything like that to call coveo from salesforce code.

Thanks and Regards, Divya

Gravatar for atheriault2@coveo.com

Comment by atheriault2, Sep 10, 2015 10:32 AM

Hi Divya,

There's no built-in API for Coveo in Salesforce to make queries. Although it is possible to make REST call using Salesforce to the Coveo Rest API maybe your best option here, depending on your setup complexity, would be to build a custom AttachToCase component using the Coveo JS Framework.

https://developers.coveo.com/display/JsSearchV1/Implementing+a+Custom+Component https://developers.coveo.com/display/SalesforceV2/BoxResultAction+Component#BoxResultActionComponent-Howtoimplementacustomresultactionitem

Gravatar for atheriault2@coveo.com

Comment by atheriault2, Sep 10, 2015 10:32 AM

An other approach could be to parse the ResultUrl field in the AttachedResult object to get the Salesforce ID. It would only work for Salesforce Object but you could use this ID to then make a SOQL query in APEX to get the data you want.

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 10, 2015 1:56 PM

Hi Thankyou so much. I will try it.

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 11, 2015 12:16 AM

Hi,

First approach that you have mentioned using Coveo Api is for UI components. But in our case, I am looking a way to get more details in apex code, so i tried second approach like parsing ResultUrl and get ID from it.

Please find more details in next comment.

Thanks, Divya

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 11, 2015 12:16 AM

For example, i have my url like following - https://cs12.salesforce.com/90630000000hYSXAA2, i did parse the url and got the ID = 90630000000hYSXAA2. I hope that value is correct for ID in this case. But using this ID, i am not sure which object to query using SOQL like Knowledge Articles, Ideas, Answers, Known Issues.

I am not even sure about the object names for above mentioned content types.

Any further details on identifying which object and corresponding names to query will help me.

Thanks, Divya

Gravatar for atheriault2@coveo.com

Comment by atheriault2, Sep 11, 2015 8:52 AM

Hi Divya,

Now that you have the Salesforce ID, you can use the Id prefix to determine the object type.

https://help.salesforce.com/apex/HTViewSolution?urlname=How-to-find-Object-Type-from-Record-ID-Prefix&language=enUS https://help.salesforce.com/apex/HTViewSolution?urlname=Standard-Field-Record-ID-Prefix-Decoder&language=enUS

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 13, 2015 9:23 PM

Hi,

The information you have provided is very useful. I am able to find the content type of attached result. Thing is I need to get more details of attached result like Article version, Content summary, Source which is not available in salesforce object. So I will have to make call to Coveo Rest Api for more details from apex code. Can you please provide me endpoint url, service url, how to send params, what object to query, etc . Any sample code would help me.

Gravatar for atheriault2@coveo.com

Comment by atheriault2, Sep 14, 2015 9:35 AM

Hi Divya,

Calling the Rest API in APEX should only be your last option here since it's a bit more complicated and hard to maintain. You should be able to get the Article Version and a Content Summary directly from APEX/SOQL. For the Source, you can get this information in the AttachedResult object; there's a field named Source.

Knowledge Article in Salesforce are a bit tricky to work with. You should be able to get the Article Version in the VersionNumber field.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforceapiobjects_knowledgearticleversion.htm

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 14, 2015 2:19 PM

Hi,

Is Content Summary related to only Knowledge Article? If other than article, Idea/Answers/KnownIssues is attached to a case, Can we get the summary of those content too?

Thanks and Regards, Divya

Gravatar for atheriault2@coveo.com

Comment by atheriault2, Sep 14, 2015 2:28 PM

Hi Divya,

You can refer to the Salesforce doc on standard objects. I know that Ideas don't have a Summary but most object have a similar field. For example, there's a Body field that you could use for Idea objects.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforceapiobjects_list.html

Gravatar for divyadevi.devara@gmail.com

Comment by divya, Sep 14, 2015 6:03 PM

Hi

Thankyou so much for all the help you did :)

Ask a question