Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Vanitha ManiVanitha Mani 

I am trying to detach a article from case when clicking the button in lightning to achieve this.

Apex class:
    public static String detachArticleToCases(String caseId, String articleId){
       List<CaseArticle> searchCaseArticleList =[select Id from CaseArticle where CaseID =:caseId];
String message = 'SUCCESS';
  if (searchCaseArticleList.size() > 0){
      CaseArticle ca = new CaseArticle(); 
      ca.CaseID = caseId; 
      ca.KnowledgeArticleId = articleId; 
      delete ca; 

return message;


Aura component:
<aura:iteration items="{!v.Knowledge__kav}" var="Knowledge__kav">
                    <td><div class="slds-truncate" title="{!Knowledge__kav.ArticleNumber}">{!Knowledge__kav.ArticleNumber}</div></td>   
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Title}">{!Knowledge__kav.Title}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.System__r.Name}">{!Knowledge__kav.System__r.Name}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Product__r.Name}">{!Knowledge__kav.Product__r.Name}</div></td>
                     <td><div class="slds-truncate" title="{!Knowledge__kav.LastPublishedDate}">{!Knowledge__kav.LastPublishedDate}</div></td>
                    <td><div class="slds-truncate" title="{!Knowledge__kav.Version__c}">{!Knowledge__kav.Version__c}</div></td>
                    <lightning:button variant="brand-outline"  label="Attach" onclick="{!c.handleClick}" value="{!Knowledge__kav.KnowledgeArticleId}"/> 
                    <lightning:button variant="brand-outline"  label="Detach" onclick="{!c.handleClick1}" value="{!Knowledge__kav.KnowledgeArticleId}"/>

 handleClick1 : function(component, event, helper) {
        var action = component.get('c.detachArticleToCases');
       let recordId = component.get("v.recordId");
     var KnowledgeArticleId = event.getSource().get("v.value");
            caseId:recordId,  // Make sure your component implemented force:hasRecordId interface
           articleId: KnowledgeArticleId 
         var state = a.getState(); // get the response state
           if(state == 'SUCCESS') {
              var toastEvent = $A.get("e.force:showToast");
                        "title": "Success!",
                        "message": "Article detached from case",
                        "type": "success"
               var toastEvent = $A.get("e.force:showToast");
                        "title": "Error!",
                        "message": "error",
                        "type": "Error"
Best Answer chosen by Vanitha Mani
Keiji OtsuboKeiji Otsubo
Hi Vanitha,

As far as I can see, it doesn't seem to be a problem.
Do you get any errors?

List<CaseArticle> searchCaseArticleList =[select Id from CaseArticle where CaseID =:caseId];
Is the count of searchCaseArticleList 1 or more?

Permissions needed to detach an article from a case
Soma Sekhar KSoma Sekhar K 
how to prevent duplicates and how to handle existing duplicate records in the org and how this is easy for admins to maintain as new changes arise?

Can anyone help on which is best practice to achieve this in my salesforce org?

Best Answer chosen by Soma Sekhar K
Coby PressCoby Press
There's actually quite a lot you can implement here.
  1. When you convert a lead, it automatically looks for accounts/contacts that already exist
  2. on a record in the related list you might see a 'no duplicates found', the system is looking for duplicates of some standard objects, if you can't see this, edit the lightning record page.
  3. probably the best one, is duplicate rules, check out this trailhead on how to create your own rules for finding duplicates in the org.

Best Answer chosen by Hieu Nguyen
Hieu NguyenHieu Nguyen
sorry i just figured it out. it was the deactivating of validation rule. 
Atqua SiddiqueAtqua Siddique 
Error type: 
" The WarehouseCalloutService class does not appear to have run successfully. Make sure that you run this class at least once before attempting this challenge. Since this class is implementing the queueable interface, you may want to wait to ensure that it has processed successfully.
Close errors." 

I added the URL in remote setting then,

My Apex Code: 
public with sharing class WarehouseCalloutService {   
    private static final String WAREHOUSE_URL = '';    
    // complete this method to make the callout (using @future) to the
    // REST endpoint and update equipment on hand.
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        HttpResponse response = http.send(request);
        if(response.getStatusCode() == 200) {
            List<Object> jsonResponse = (List<Object>)JSON.deserializeUntyped(response.getBody());
            system.debug('~~ '+jsonResponse);
            List<Product2> productList = new List<Product2>();
            for(Object ob : jsonResponse) {
                Map<String,Object> mapJson = (Map<String,Object>)ob;
                Product2 pr = new Product2();
                pr.Replacement_Part__c = (Boolean)mapJson.get('replacement');
                pr.Name = (String)mapJson.get('name');
                pr.Maintenance_Cycle__c = (Integer)mapJson.get('maintenanceperiod');
                pr.Lifespan_Months__c = (Integer)mapJson.get('lifespan');
                pr.Cost__c = (Decimal) mapJson.get('lifespan');
                pr.Warehouse_SKU__c = (String)mapJson.get('sku');
                pr.Current_Inventory__c = (Double) mapJson.get('quantity');
                upsert productList;

After this I run: WarehouseCalloutService.runWarehouseEquipmentSync(); in Anonymous window
Later run the query in query editor - "SELECT Id, JobType, MethodName, Status, createddate FROM AsyncApexJob WHERE CompletedDate = TODAY" 

Also find few are completed and few as failed after executing the query.

But still, the challenge is not completed not sure y ??
Best Answer chosen by Atqua Siddique
Keiji OtsuboKeiji Otsubo
Hi Atqua,

Please check this article.
Kyle BlaneyKyle Blaney 
What are possible reasons that two users with the same profile (System Administrator) and same permissions would see different fields? I have excluded as possible reasons:
  • page layouts (the users have the same profile)
  • permission sets (neither user has any)
I have tried the following without success:
  • Disable browser caching in Setup | Session Settings.
  • Remove the field from the page layout and then re-add it.
  • Change the field-level security to invisible, then change it back to read/write.
  • Use different browsers and force browsers to reload.
  • Use different computers.
An example field that one user can't see is Contact->Age. It's field-level security is set to Visible for the System Administrator profile. I know it appears on the page layout because one user can see it.
Best Answer chosen by Kyle Blaney
Kyle BlaneyKyle Blaney
I figured it out!

The problem was caused by licenses to an installed package. The fields that are only visible to me are part of an installed package to which I have a license. The users that can't see the fields don't have a license.

Thanks for all your time, Manoj!
Deepika BhattaDeepika Bhatta 
I am having a problem while creating a user Lincoln Ulrich. It does not let me check Marketing User in his profile.
Best Answer chosen by Deepika Bhatta
Balaji VadlamudiBalaji Vadlamudi
That means you have used all the available licenses. You can disable one of the existing users to free up licenses.

Go to Setup -> Company Information to see license information.
Emily HolthausEmily Holthaus 
Hi there,

I have the below validation rule active in our org. It works well, but I need to edit the rule so it won't apply to one single user. What do I need to add to the formula?

AND(RecordType.Name ="3rd Party",
ISPICKVAL(Opportunity_Business_Type__c , "New Business"),
OR( ISPICKVAL(StageName, "Activate & Transition"),
ISPICKVAL(StageName, "Retain & Grow")
ISPICKVAL(X3rd_Party_Pricing_Approval__c, "Rejected")))

Thank you!

Best Answer chosen by Emily Holthaus
Steve MolisSteve Molis
$User.Username <> "",
RecordType.Name ="3rd Party",
ISPICKVAL(Opportunity_Business_Type__c , "New Business"),
ISPICKVAL(StageName, "Activate & Transition"),
ISPICKVAL(StageName, "Retain & Grow")
ISPICKVAL(X3rd_Party_Pricing_Approval__c, "Rejected")

Jonathan TobiasJonathan Tobias 

I need a validation rule for opportunities

If the opportunity stage 'Closed Won'
and activation methods = managed service - illumin

then the following fields CANNOT be blank:

Client bought illumin (checkbox field) must be checked
illumin pricing structure (picklist)
why illumin? (open text)
priority focus (picklist)
what is client expected journey (open text)
what is client looking to learn (open text)
additional illumin notes (open text)
awareness stage format (multi-select picklist)
awareness stage goal (open text)
engagement stage format (multi select picklist)
engagement stage goal (open text)
conversion stage format (multi select picklist)
conversion stage goal (multi select picklist)
creative messaging per stage (open text)

Best Answer chosen by Jonathan Tobias
Steve MolisSteve Molis
Sorry, missed a comma

TEXT( StageName ) = 'Closed - Won',
TEXT(Activation_Methods__c) = 'managed service - illumin',
Client_Bought_illumin__c = FALSE,
ISBLANK(TEXT(illumin_Pricing_Structure__c )),
ISBLANK(Why_illumin__c ),
ISBLANK(TEXT(Journey_Focus__c )),
ISBLANK(What_is_client_expected_journey__c ),
ISBLANK(What_is_client_looking_to_learn__c ),
ISBLANK(Additional_illumin_Notes__c ),
ISBLANK(Awareness_Stage_Format__c ),
ISBLANK(Awareness_Stage_Goal__c ),
ISBLANK(Engagement_Stage_Format__c ),
ISBLANK(Engagement_Stage_Goal__c ),
ISBLANK(Conversion_Stage_Format__c ),
ISBLANK(Conversion_Stage_Goal__c ),
Megan BlotzerMegan Blotzer 
How can I write this as a formula? 

If Opp Stage is Closed Won and Live Date (custom date field) is not blank, then multiply Custom_Currency_Field__c by 50%
Best Answer chosen by Megan Blotzer
Andreea DorofteiAndreea Doroftei
Hello Megan, 

Would you mind trying out the below? 

AND(ISPICKVAL(StageName,"Closed Won"),NOT(ISBLANK(Live_Date__c))),

​​​​​​​Let me know how it goes :) 
scott chappellscott chappell 
Mars Rover Process Builder challenge... problem with the message not being able to save....
Best Answer chosen by scott chappell
scott chappellscott chappell

Thank you will review the article in the tomorrow and try again... perhaps working in a different playground just might solve the issue...
Thanks for suggestion