You need to sign in to do that
Don't have an account?
paul-lmi
Bug/inconsistent behavior with CaseArticle vs. CaseSolution
/** * addSolutionToCase inserts an entry to the CaseSolution table * @param solutionId string representing a valid Solution ID * @param caseId string representing a valid case ID **/ public static void addSolutionToCase(string solutionId, string caseId){ CaseSolution c = new CaseSolution(); c.SolutionId = solutionid; c.caseid = caseid; insert c; }
this works, even if a "duplicate" would be inserted. it silently catches the dupe and does nothing
/** * addArticleToCase inserts an entry to the CaseArticle table * @param knowledgearticleid string representing a valid KnowledgeArticleId * @param caseId string representing a valid CaseId **/ public static void addArticleToCase(string knowledgearticleid, string caseId){ CaseArticle a = new CaseArticle(); a.caseId = caseId; a.knowledgearticleid = knowledgearticleid; insert a; }
this fails with "Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []" if i try to insert a duplicate value.
So two issues here.
- CaseArticle insert logic is different from CaseSolution, where the functionality and use case for the two objects are identical.
- The error being thrown is useless, since it doesn't give me the value that's a dupe, and it doesn't give me the record affected, and it doesn't give me the row number of the error.
paul-lmi
adding on, i also can't use Upsert because the CaseId and KnowledgeArticleId fields on this junction object aren't detected as "indexed" by the system, so my choices to work around this bug are either silently catching the exception or doing a query to confirm whether the item exists before i do the insert. both are not ideal in my eyes.