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

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

Apex class:
@AuraEnabled
    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">
                <tr>  
                  
                    <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}"/>
                                    
                </tr>
            </aura:iteration>

Controller:
 handleClick1 : function(component, event, helper) {
        var action = component.get('c.detachArticleToCases');
       let recordId = component.get("v.recordId");
     var KnowledgeArticleId = event.getSource().get("v.value");
      
       action.setParams({
            caseId:recordId,  // Make sure your component implemented force:hasRecordId interface
           articleId: KnowledgeArticleId 
       });
       action.setCallback(this,function(a){
         var state = a.getState(); // get the response state
           if(state == 'SUCCESS') {
              var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Success!",
                        "message": "Article detached from case",
                        "type": "success"
                    });
        toastEvent.fire();
            }
           else{
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        "title": "Error!",
                        "message": "error",
                        "type": "Error"
                    });
        toastEvent.fire();
           }
        });
        $A.enqueueAction(action);
       $A.get('e.force:refreshView').fire();
    },
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
https://help.salesforce.com/articleView?id=000339821&type=1&mode=1
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?

Thanks
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. 

https://trailhead.salesforce.com/en/content/learn/modules/contact-and-account-settings-in-nonprofit-success-pack/merge-duplicate-contacts-and-accounts-npsp


https://powerofus.force.com/s/article/NPSP-Merging-Contacts

https://www.salesforce.org/blog/duplicate-management-nonprofit-starter-pack/

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 = 'https://th-superbadge-apex.herokuapp.com/equipment';    
    // complete this method to make the callout (using @future) to the
    // REST endpoint and update equipment on hand.
    @future(callout=true)
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setMethod('GET');
        request.setEndpoint(WAREHOUSE_URL);
        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');
                productList.add(pr);
            }            
            if(productList.size()>0)
                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.

https://trailblazers.salesforce.com/answers?id=9064S000000DRyLQAW
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")
),
OR(
ISPICKVAL(X3rd_Party_Pricing_Approval__c,''),
ISPICKVAL(X3rd_Party_Pricing_Approval__c, "Rejected")))


Thank you!

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

 
Jonathan TobiasJonathan Tobias 
Hello,

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

AND(
TEXT( StageName ) = 'Closed - Won',
TEXT(Activation_Methods__c) = 'managed service - illumin',
OR(
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 ),
ISBLANK(Creative_Messaging_Per_Stage__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? 

IF(
AND(ISPICKVAL(StageName,"Closed Won"),NOT(ISBLANK(Live_Date__c))),
Custom_Currency_Field__c*0.5,null)

​​​​​​​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
Keiji,

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