function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kenji776Kenji776 

Grab Resolution Text from Solution

Hello all,
Me again with another project. To try and make the case process easier, we want to be able to have a button that copies the text from the SolutionNote field in the attached solution, and copy it into the resolution field of the case, then close it. The problem is that I cannot find how to link Case->Case Solution->Solutions. The Case Solution is what gets linked to the case in the attached solution, and that does not contain the SolutionNote field that contains the text I need. So I basically need to write two queries, one to find the ID of the solution is the Case Solution table, then another to grab the SolutionNote from the Solutions table. The problem is that half the fields don't seem to be queryable, like I'll go to grab "CaseSolutions" from the Solution table, and it will say invalid column name.

<element name="CaseSolutions" nillable="true" minOccurs="0" type="tns:QueryResult"/>

Anyway, does anybody have any ideas on how I can do this. Just a simple button that copies the text from the
Solution.SolutionNote
Field and put it into
Cases.Resolution__c

Thanks!

werewolfwerewolf
First question: why are you copying that solution note to the case details?  Is it to email the customer with solutions?  If that's the case, then you can actually just put the attached solutions inline in your email template using a merge field.

The reason you're getting this error is because CaseSolution is a linking table.  It just contains the ID of a case and the ID of a solution.  To get the field from the solution you have to go one level deeper and query the solution note given the ID from the CaseSolution table.
Kenji776Kenji776
Thanks for your reply!
A very good though to just copy the text from the attached solution into the email, probabaly the easiest way to go. The only problem is that sometimes, for simple cases we don't look up and attach solutions, we just write something in the resolution field, and close it out and send it. I guess my email could just have both the resolution, and the solutionnote field right after each other in the template, that way, whichever one is filled out would be sent along, that could probably work. I guess I would just like the resolution field to get filled out for completness sake, I hate empty fields :P. My boss is the one who requested this feature, so I'll ask it what you suggested would be okay instead, still I'd like to know the code on how to do it, if it's easy, because I'm sure I want something like that somewhere else in the future.

For the part about the querying, I thought that was what i was doing. Grab the solution id from the casesolution table, and query that solution id in the solutions table and pull the solutionnote. I am missing something or did I explain myself poorly (quite possible). So the process would go...

1) Query Case for it if has attached solution
2) Query Case Solution table to get the solution Id that is attached
3) Query the Solution table with the Id returned from the previouse query
4) Save the Solutionnote into a variable
5) Copy the value of that variable into the Case resolution field
6) Update salesforce with the new value.

Any sample code would be much appreciated, since I'm such a dang newb. Thanks!
HardhatHardhat
The pseudocode you've written is correct.  Also, the idea of putting the resolution and the attached solutions side-by-side is a good one.