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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 22
    Replies
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; 
     
    }
    
}
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;
        }
    }
}








 
//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; 
     
    }
    
}