• Hitesh Khanna
  • NEWBIE
  • 130 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 28
    Replies
@AuraEnabled
    public static String getContentDetails(String recordId) {
        List<ContentDocumentLink> contentDocumentList = [SELECT ContentDocumentId, LinkedEntityId 
                                                            FROM   ContentDocumentLink 
                                                            WHERE  LinkedEntityId =: recordId];
        Set<Id> contentDocumentId = new Set<Id>();
            
        for(ContentDocumentLink cdl : contentDocumentList){
            contentDocumentId.add(cdl.ContentDocumentId);
        }
            
        List<ContentVersion> contentVersionList = [SELECT Id, VersionData, FileType, Title, FileExtension,Last_Updated_Date__c,
                                                    Comments__c,Last_Updated__c,Baseline_Category__c,CreatedBy.Name, ContentDocument.ContentSize,
                                                    CreatedDate, ContentDocumentId, ContentDocument.FileType
                                                    FROM   ContentVersion 
                                                    WHERE  ContentDocumentId IN : contentDocumentId order by Last_Updated_Date__c DESC ];
      
        return JSON.serialize(contentVersionList);
    }
This is my method for which i want to write test class
 
Hi,
I have one field in my lightning-datatable and i want to make its value as link , so that it can download through a url provided .
how do i achieve that ?
{ label: 'File Uploaded',  fieldName: 'Title', sortable:true}

NOTE: I have tried giving the type:url' for the field but it converts the value to https://. for e.g field value is abc, it displays it as https:/ab.com/ which is not what i want.
This is my method :
public static List<String> UpdateStatus(List<String> recordId ){
        //Fetch the current values in sub status multiselect picklist
        GPO_Rebate_Payment__c gpopayment = [SELECT Sub_Status__c,Status__c FROM GPO_Rebate_Payment__c where id IN :recordId LIMIT 1];
         List<String> currentStatusValues = gpopayment.Sub_Status__c.split(';');
        
        If(gpopayment.Status__c == 'Pharma Payment')
        {
            if(!currentStatusValues.Contains('Overdue'))
            {
                 currentStatusValues.add('Overdue');
            }
        }
        else{
            if(currentStatusValues.Contains('Overdue'))
            {     
                for(Integer i = currentStatusValues.size() - 1; i >= 0; i--) {
                if(currentStatusValues[i].equals('Overdue')) 
                {
                currentStatusValues.remove(i);
                }
    }
                 //currentStatusValues.('Overdue');
            }
        /* String newStatusValues;
        newStatusValues = string.join(currentStatusValues ,';');
         gpopayment.Sub_Status__c = newStatusValues;*/
    
    }
        return currentStatusValues;

}

i have written this test method but it is giving me error of illegal assignment from List to List:
@isTest
    public static void UpdateStatusTest(){
        GPO_Rebate_Payment__c gpopayment = new GPO_Rebate_Payment__c();
        gpopayment.name = 'test class';
        gpopayment.Status__c = 'Pharma Payment';
        gpopayment.Sub_Status__c = 'In Progress';
        
        update gpopayment;
        
        test.startTest();
        List<String> recid = [SELECT Id FROM GPO_Rebate_Payment__c WHERE name='test class'];
        GPORebatePaymentSubStatusUpdate.UpdateStatusTest(recid.Id);
        test.stopTest();

 
I have a table in my LWC component containing two columns 'name' and 'id'. The values of these columns will come based on filters that i have added(so the values will be different everytime, not hardcoded).
I want to iterate over these values and store it an array.
How can i iterate over these values in table.
AND(ISPICKVAL(Status__c , 'Pharma Payment'), ISBLANK(InvoiceFile__c), RecordType.DeveloperName ='With_Invoicing',NOT(ISNEW()))
custom permission is :    $Permission.Bypass_Rebate_Payment_Status_Change_Validation 

where and how do i put this inside my validation rule to exclude it ?
 
this is the formula and i want to display text in red colour.

IF( Contract_End_Date__c <  TODAY() , "Please do not utilize the playbook. The contract is no longer active" , " ")
I wrote this. But its not wokrking if one of the fields is blank(but working if both are blank). what changes should i make ?
IF(
AND(NOT(ISBLANK( abc__c )) , NOT(ISBLANK( xyz__c ))) ,


IMAGE("/servlet/servlet.ImageServer?id=0150R000001JUkT&oid="+$Organization.Id, "icon" ,24, 128),
""
)

 
"User cannot change status to invoicing if previous status was Pharma Payment, Member Payout, Payment Processing, or Complete".......(these are the picklist values) .


I tried this..but its not working.


IF(ISPICKVAL(Status__c,'Invoicing'), 
    ISPICKVAL(Status__c, 'Pharma Payment') ||
    ISPICKVAL(Status__c, 'Member Payout') ||
    ISPICKVAL(Status__c, 'Payment Processing') ||
    ISPICKVAL(Status__c, 'Complete')
 ,
false )



Response will be appreciated.


 
 public static Map<ID, ContentVersion> getRelatedFilesByRecordId(String recordId) {
        system.debug('recordId-->'+recordId);
        // Get record file IDs        
        List<ContentDocumentLink> files = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :recordId];
        List<ID> fileIDs = new List<ID>();
        for (ContentDocumentLink docLink : files) {
            fileIDs.add(docLink.ContentDocumentId);
        }
        system.debug('fileIDs-->'+fileIDs);
        List<ContentVersion> docs = [SELECT ContentDocumentId, FileExtension, Title, CreatedDate,Document_Name__c,FileType,Comments__c 
            FROM ContentVersion WHERE ContentDocumentId IN : fileIDs Order by CreatedDate DESC ];
        Map<ID, ContentVersion> mapIdTitle = new Map<ID, ContentVersion>();
        for (ContentVersion docLink : docs) {
            mapIdTitle.put(docLink.ContentDocumentId, docLink);
        }
       
        return mapIdTitle;
    }
@AuraEnabled(cacheable=true)
    public static EmbedTokenDetails getEmbedToken(String workspaceId, String reportId, String datasetId) {
       
        EmbedTokenDetails result = new EmbedTokenDetails();

        String access_token = getAccessToken();
        if(String.isNotBlank(access_token)){
            Http http = new Http();        
            HttpRequest reqGetEmbedToken = new HttpRequest();
            reqGetEmbedToken.setMethod('POST');
            String urlGetEmbedToken = 'https://api.powerbi.com/v1.0/myorg/groups/' + workspaceId + '/reports/' + reportId + '/GenerateToken';
            reqGetEmbedToken.setEndpoint(urlGetEmbedToken);
            reqGetEmbedToken.setHeader('Authorization', 'Bearer ' + access_token);    
            reqGetEmbedToken.setBody('{"accessLevel": "View", "datasetId": "' + datasetId + '"}');
    
            HttpResponse responseEmbedToken = http.send(reqGetEmbedToken);
            
            if(responseEmbedToken.getStatusCode()!=200){
                System.debug('Embed Token Response Status: '+responseEmbedToken.getStatus());
                System.debug('Embed Token Response Status Code: ' + responseEmbedToken.getStatusCode());
                System.debug('Embed Token Response Body: ' + responseEmbedToken.getBody());  
                // TREN:805 -> throw exception here that has the body in the exception message
                // concatenate status code with body
                return result;            
            }
            
            Map<String, Object> responseBody = (Map<String, Object>) JSON.deserializeUntyped(
                responseEmbedToken.getBody()
            );
            result.embedToken = (String) responseBody.get('token');
            result.embedTokenExpiration = (String) responseBody.get('expiration');

            system.debug('@@@result.embedToken:' + result.embedToken);
            system.debug('@@@result.embedTokenExpiration:' + result.embedTokenExpiration);
        }
        return result;
    }
 
//PLEASE NOTE THAT THESE ARE 3 CUSTOM OBJECTS IN MY ORG.


public without sharing class EmbeddedAnalyticsAppCtrl {
   
    @AuraEnabled(cacheable=true)
    public static List<Embedded_Analytics_App_Item__c> getPowerBIAppItem(String appName) {
        try {
            return [
                SELECT
                    Name, Max_Width_Pixels__c,
                    Max_Height_Pixels__c,
                    Show_Action_Bar__c,
                    Apply_Transparent_Background__c,
                    Embedded_Analytics_Report__r.Report_Id__c,
                    Embedded_Analytics_Report__r.Workspace_Id__c,
                    Embedded_Analytics_Report__r.Record_Type__c,
                    Embedded_Analytics_Report__r.Embed_URL__c,
                    Embedded_Analytics_Report__r.Aspect_Height_Ratio__c,
                    Embedded_Analytics_Report__r.Aspect_Width_Ratio__c,
                    Embedded_Analytics_Report__r.Dataset_Id__c,
                    Embedded_Analytics_Report__r.Description__c
                FROM Embedded_Analytics_App_Item__c
                WHERE
                    Embedded_Analytics_App_Instance__r.App_Name__c = :appName
                    AND Embedded_Analytics_App_Instance__r.Is_Active__c = TRUE
                    AND Embedded_Analytics_Report__r.Is_Active__c = TRUE
                    AND Is_Active__c = TRUE
                    AND Embedded_Analytics_Report__r.Record_Type__c = 'PowerBI Report'
            ];
        } catch (Exception ex) {
            system.debug('@@@error message:' + ex.getLineNumber());
            return null;
        }
    }
}








 
//Display.cls

public with sharing class Display {
    @AuraEnabled(cacheable=true)
    public static Integer total(String status){
        Return [SELECT COUNT() FROM Contract WHERE Status =: status];
    }
}




//displayTotal.html

<template>
    <lightning-card title="Total Contracts" >
        <div class="slds-m-around_medium">
            <template if:true={a.data}>
               <div class="data">
                {a.data}
               </div>
            </template>
            <template if:true={a.error}>
                <div class="data">
                    {a.error}
                   </div>                
            </template>
        </div>
        <footer>Loreum Ipsum picslum</footer>
    </lightning-card>
</template>



//displayTotal.js

import { api, LightningElement, wire } from 'lwc';
import total from '@salesforce/apex/Display.total'
export default class DisplayTotal extends LightningElement {
    @api Status;
    @wire(total,{status:'$Status'}) a;
    
}
 
trigger contactTrigger on Contact (before insert,after insert,before update,after update,after undelete,after delete)
{
    if(trigger.isAfter){
        List<Contact> contactList = new List<Contact>();
        Set<Id> accountIdSet= new Set<Id>();
        if(trigger.isDelete){
            contactList=Trigger.old;
        }else{
            contactList=Trigger.new;
        }
        
        for(Contact con :contactList){
            if(con.AccountId!=null){
                accountIdSet.add(Con.AccountId);
            }
            if(Trigger.isUpdate){
                 Contact oldContact  = (Contact)Trigger.oldMap.get(con.Id);
            if(oldContact.AccountId != con.AccountId){
                accountIdSet.add(oldContact.AccountId);
            }
            }
           
        }
      List<Account> accountList = [SELECT Id,Name,Number_Of_Contacts__c,(select Id,Name From Contacts)
                                   FROM Account 
                                  WHERE Id IN:accountIdSet];
        for(Account acc: accountList){
            List<Contact> relatedContacts = acc.Contacts;
            if(relatedContacts !=null){
                acc.Number_Of_Contacts__c = relatedContacts.size();
                
            }else{
                acc.Number_Of_Contacts__c=0;
            }
        }
        update accountList; 
     
    }
    
}
@AuraEnabled
    public static String getContentDetails(String recordId) {
        List<ContentDocumentLink> contentDocumentList = [SELECT ContentDocumentId, LinkedEntityId 
                                                            FROM   ContentDocumentLink 
                                                            WHERE  LinkedEntityId =: recordId];
        Set<Id> contentDocumentId = new Set<Id>();
            
        for(ContentDocumentLink cdl : contentDocumentList){
            contentDocumentId.add(cdl.ContentDocumentId);
        }
            
        List<ContentVersion> contentVersionList = [SELECT Id, VersionData, FileType, Title, FileExtension,Last_Updated_Date__c,
                                                    Comments__c,Last_Updated__c,Baseline_Category__c,CreatedBy.Name, ContentDocument.ContentSize,
                                                    CreatedDate, ContentDocumentId, ContentDocument.FileType
                                                    FROM   ContentVersion 
                                                    WHERE  ContentDocumentId IN : contentDocumentId order by Last_Updated_Date__c DESC ];
      
        return JSON.serialize(contentVersionList);
    }
This is my method for which i want to write test class
 
Hi,
I have one field in my lightning-datatable and i want to make its value as link , so that it can download through a url provided .
how do i achieve that ?
{ label: 'File Uploaded',  fieldName: 'Title', sortable:true}

NOTE: I have tried giving the type:url' for the field but it converts the value to https://. for e.g field value is abc, it displays it as https:/ab.com/ which is not what i want.
This is my method :
public static List<String> UpdateStatus(List<String> recordId ){
        //Fetch the current values in sub status multiselect picklist
        GPO_Rebate_Payment__c gpopayment = [SELECT Sub_Status__c,Status__c FROM GPO_Rebate_Payment__c where id IN :recordId LIMIT 1];
         List<String> currentStatusValues = gpopayment.Sub_Status__c.split(';');
        
        If(gpopayment.Status__c == 'Pharma Payment')
        {
            if(!currentStatusValues.Contains('Overdue'))
            {
                 currentStatusValues.add('Overdue');
            }
        }
        else{
            if(currentStatusValues.Contains('Overdue'))
            {     
                for(Integer i = currentStatusValues.size() - 1; i >= 0; i--) {
                if(currentStatusValues[i].equals('Overdue')) 
                {
                currentStatusValues.remove(i);
                }
    }
                 //currentStatusValues.('Overdue');
            }
        /* String newStatusValues;
        newStatusValues = string.join(currentStatusValues ,';');
         gpopayment.Sub_Status__c = newStatusValues;*/
    
    }
        return currentStatusValues;

}

i have written this test method but it is giving me error of illegal assignment from List to List:
@isTest
    public static void UpdateStatusTest(){
        GPO_Rebate_Payment__c gpopayment = new GPO_Rebate_Payment__c();
        gpopayment.name = 'test class';
        gpopayment.Status__c = 'Pharma Payment';
        gpopayment.Sub_Status__c = 'In Progress';
        
        update gpopayment;
        
        test.startTest();
        List<String> recid = [SELECT Id FROM GPO_Rebate_Payment__c WHERE name='test class'];
        GPORebatePaymentSubStatusUpdate.UpdateStatusTest(recid.Id);
        test.stopTest();

 
AND(ISPICKVAL(Status__c , 'Pharma Payment'), ISBLANK(InvoiceFile__c), RecordType.DeveloperName ='With_Invoicing',NOT(ISNEW()))
custom permission is :    $Permission.Bypass_Rebate_Payment_Status_Change_Validation 

where and how do i put this inside my validation rule to exclude it ?
 
I wrote this. But its not wokrking if one of the fields is blank(but working if both are blank). what changes should i make ?
IF(
AND(NOT(ISBLANK( abc__c )) , NOT(ISBLANK( xyz__c ))) ,


IMAGE("/servlet/servlet.ImageServer?id=0150R000001JUkT&oid="+$Organization.Id, "icon" ,24, 128),
""
)

 
 public static Map<ID, ContentVersion> getRelatedFilesByRecordId(String recordId) {
        system.debug('recordId-->'+recordId);
        // Get record file IDs        
        List<ContentDocumentLink> files = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :recordId];
        List<ID> fileIDs = new List<ID>();
        for (ContentDocumentLink docLink : files) {
            fileIDs.add(docLink.ContentDocumentId);
        }
        system.debug('fileIDs-->'+fileIDs);
        List<ContentVersion> docs = [SELECT ContentDocumentId, FileExtension, Title, CreatedDate,Document_Name__c,FileType,Comments__c 
            FROM ContentVersion WHERE ContentDocumentId IN : fileIDs Order by CreatedDate DESC ];
        Map<ID, ContentVersion> mapIdTitle = new Map<ID, ContentVersion>();
        for (ContentVersion docLink : docs) {
            mapIdTitle.put(docLink.ContentDocumentId, docLink);
        }
       
        return mapIdTitle;
    }
//PLEASE NOTE THAT THESE ARE 3 CUSTOM OBJECTS IN MY ORG.


public without sharing class EmbeddedAnalyticsAppCtrl {
   
    @AuraEnabled(cacheable=true)
    public static List<Embedded_Analytics_App_Item__c> getPowerBIAppItem(String appName) {
        try {
            return [
                SELECT
                    Name, Max_Width_Pixels__c,
                    Max_Height_Pixels__c,
                    Show_Action_Bar__c,
                    Apply_Transparent_Background__c,
                    Embedded_Analytics_Report__r.Report_Id__c,
                    Embedded_Analytics_Report__r.Workspace_Id__c,
                    Embedded_Analytics_Report__r.Record_Type__c,
                    Embedded_Analytics_Report__r.Embed_URL__c,
                    Embedded_Analytics_Report__r.Aspect_Height_Ratio__c,
                    Embedded_Analytics_Report__r.Aspect_Width_Ratio__c,
                    Embedded_Analytics_Report__r.Dataset_Id__c,
                    Embedded_Analytics_Report__r.Description__c
                FROM Embedded_Analytics_App_Item__c
                WHERE
                    Embedded_Analytics_App_Instance__r.App_Name__c = :appName
                    AND Embedded_Analytics_App_Instance__r.Is_Active__c = TRUE
                    AND Embedded_Analytics_Report__r.Is_Active__c = TRUE
                    AND Is_Active__c = TRUE
                    AND Embedded_Analytics_Report__r.Record_Type__c = 'PowerBI Report'
            ];
        } catch (Exception ex) {
            system.debug('@@@error message:' + ex.getLineNumber());
            return null;
        }
    }
}