• chikku
  • NEWBIE
  • 50 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 14
    Replies
Hi all,
I need an apex class to get a standard object called documentlink field called LinkedEntityId.
 when document upload. It should automatically create a task.
 This my code:

trigger CreateTask on ContentVersion (after insert)
{
List<Task> insertTask = new List<Task>();
Task newTask = new Task();
for(ContentVersion newCase : Trigger.new)
{
newTask.subject = 'Document Expiration';
newTask.ActivityDate = newCase.Expiry_Date__c;
newTask.ownerId = newCase.OwnerId;
newTask.status = 'Not started';
newTask.Priority = 'Normal';
if('ObjAPiName' == 'Contact')
{
newTask.WhoId = //Contact ;
}
else
{

newTask.WhatId =[select LinkedEntityId from ContentDocumentLink where ContentDocumentId IN : newCase.ContentDocumentId].Id; // this  code I impletement to get LinkedEntityId from ContentDocumentLink
}
insert newTask;

if(insertTask.isEmpty())
{
try{

}catch(DmlException de)
{
System.debug(de);
}
}
}
}
I need to assign LinkedEntityId this id to create task.
Trigger -> WhoId.

Is anyone help?
Thanks in advance.
  • December 12, 2020
  • Like
  • 0
I have a check- box "Called Active" and other fields called "completion date with date picker" when the completion date is completed or end, automatically Active check box should be disabled or false. there is any solution there?
  • November 16, 2020
  • Like
  • 0
I have created Navigation to achieve the related list in Subtab in lwc it throws an error while clicking the Navigation. I Have updated the code This was an error my facing it while clicking the view navigation.User-added image
const actions = [
    { label: 'View', name: 'view' },
    { label: 'Edit', name: 'edit' },
];
 
const columns = [   
   
 { label: 'Sort Code', fieldName: 'Sort_Code__c' },
 {label:'Account Number', fieldName:'Account_Number__c'},
    {
        type: 'action',
        typeAttributes: { rowActions: actions },
    }, 
];
        },
        handleRowActions( event ) {

        const actionName = event.detail.action.name;
        const row = event.detail.row;
        switch ( actionName ) {
            case 'view':
                this[NavigationMixin.Navigate]({
                    type: 'standard__recordPage',
                    attributes: {
                        recordId: row.Id,
                        actionName: 'view'
                    }
                });
                break;
            case 'edit':
                this[NavigationMixin.Navigate]({
                    type: 'standard__recordPage',
                    attributes: {
                        recordId: row.Id,
                        objectApiName: 'Bank_Account__c',
                        actionName: 'edit'
                    }
                });
                break;
            default:
        }

    }

 
  • September 28, 2020
  • Like
  • 0
A Contact__c is the parent of a custom object in our org (Relationship) with tree__c .the same filed name is contact__c in Tree__c object. I would like to get the parent record's ID with the child record's ID any time there is a new Relationship created. How would I get the record ID of the Account record and the Relationship record in an apex class?
  • September 22, 2020
  • Like
  • 0
I have  Account__c and Contact__c, which Account__c  have lookup with Contact__c  with filed Client__c,I need to write insert record id of look up.there is any solution.
  • September 18, 2020
  • Like
  • 0
It is possible to create custom related to fields in lighting form or lwc possible.
I need like this in custom by using lwc or lighting record form?
User-added image
  • September 11, 2020
  • Like
  • 0
User-added imageThe above pic is an error, here is the code.

TimelineEventController:
public class TimelineEventController implements IController, ITimelineEventController{
 
 
    public static List<SObject> getAll(){
         return [SELECT
                      Name,Event_Date__c,Event_Type__c,Related_Id__c,Related_Object_Name__c,
                      Related_User_Id__c,Title__c,Description__c,Object_Id__c
                 FROM Timeline_Event__c
                 ORDER BY CreatedDate DESC
                 LIMIT 1000];                         
     }
 
     @AuraEnabled
     public static List<SObject> getAll(SObject value){
         return getAll(value,null);
     }
 
     public static List<SObject> getAll(SObject value,String autoNumber){
         Timeline_Event__c param = (Timeline_Event__c)value;
         String queryString = 'Select Name,Event_Date__c,Event_Type__c,Related_Id__c,Object_Id__c,'+
                               'Related_User_Id__c,Title__c,Subtitle__c,Description__c,Related_Object_Name__c'+
                         ' from Timeline_Event__c where';
 
         if(!string.isBlank(autoNumber)){
             queryString += ' Name = \'' + String.escapeSingleQuotes(autoNumber) +  '\' AND';
         }
         if(param.Event_Date__c  != Null){
             queryString += ' Event_Date__c = '+ param.Event_Date__c +' AND';
         }
         if (!string.isBlank(param.Object_Id__c)) {
             queryString += ' Object_Id__c = \'' + String.escapeSingleQuotes(param.Object_Id__c) + '\' AND';
         }
         
         if (!string.isBlank(param.Event_Type__c)) {
             queryString += ' Event_Type__c = \'' + String.escapeSingleQuotes(param.Event_Type__c) + '\' AND';
         }
 
         if (!string.isBlank(param.Related_Id__c)) {
             queryString += ' Related_Id__c = \'' + String.escapeSingleQuotes(param.Related_Id__c) + '\' AND';
         }
 
         if (!string.isBlank(param.Related_User_Id__c)) {
             queryString += ' Related_User_Id__c = \'' + String.escapeSingleQuotes(param.Related_User_Id__c) + '\' AND';
         }
 
         if (!string.isBlank(param.Title__c)) {
             queryString += ' Title__c = \'' + String.escapeSingleQuotes(param.Title__c) + '\'';
         }
 
         queryString = queryString.removeEnd(' AND');
         List<SObject> timeline=Database.query(queryString);
         return timeline;
     }
 
     @AuraEnabled
     public static SObject getById(Id id){
         SObject entity = [SELECT
                             Name,Event_Date__c,Event_Type__c,Related_Id__c,Object_Id__c,
                              Related_User_Id__c,Title__c,Subtitle__c,Description__c, Related_Object_Name__c
                         FROM Timeline_Event__c
                         WHERE Id=:id];
         return entity; 
     }
    
   
     public Id create(SObject value) {
         Timeline_Event__c entity = (Timeline_Event__c)value;
         insert entity;
         return entity.Id;
     }
 
     public Boolean createMany(List<SObject> values) {
         List<Timeline_Event__c> entities = (List<Timeline_Event__c>)values;
         insert entities;
         return true;
     }
 
     public Boolean edit(SObject value) {
         Timeline_Event__c entity = (Timeline_Event__c)value;
         update entity;
         return true;
     }
 
     public Boolean editMany(List<SObject> values) {
         List<Timeline_Event__c> entities = (List<Timeline_Event__c>)values;
         update entities;
         return true;
     }
     public Boolean remove(Id id) {
         Timeline_Event__c entity = [SELECT Id FROM Timeline_Event__c WHERE Id=:id];
         delete entity; 
         return true;
     }
 
    @AuraEnabled
    public static List<SObject> getAllByLimit(Id id,Integer l){
        List<sObject> entities=[SELECT
                      Name,Event_Date__c,Event_Type__c,Related_Id__c,Object_Id__c,
                      Related_User_Id__c,Title__c,Subtitle__c,Description__c, Related_Object_Name__c
                 FROM Timeline_Event__c
                 WHERE Object_Id__c = :id
                 ORDER BY Id DESC
                 LIMIT :l]; 
        return entities;
    }
    
    
    public static SObject timelineTrigger(SObject obj,string tit,string sub,string des,string etype,string dml,string objName){
        Timeline_Event__c tobj=new Timeline_Event__c();
        SObject sObj;
      
     
        string objId='';
        if(objName=='application'){
        	sObj=(Application__c)obj;   
            tobj.Related_Object_Name__c='Application__c';
            if(sObj.get('Account__c')!=null){
                tobj.Object_Id__c=(string)sObj.get('Account__c');
            }
            else{
                tobj.Object_Id__c=(string)sObj.get('Contact__c');
            }
        }
        else if(objName=='bank'){
            sObj=(Bank_Account__c)obj;
            tobj.Related_Object_Name__c='Bank_Account__c';
            if(sObj.get('Account__c')!=null){
                tobj.Object_Id__c=(string)sObj.get('Account__c');
            }
            else{
                tobj.Object_Id__c=(string)sObj.get('Client__c');
            }
        }
        else if(objName=='benefit'){
            sObj=(Benefit__c)obj;
            tobj.Related_Object_Name__c='Benefit__c';
            tobj.Object_Id__c=(string)sObj.get('Contact__c');
        }
        else if(objName=='contact'){
            sObj=(Contact)obj;
            tobj.Related_Object_Name__c='Contact';
            tobj.Object_Id__c=(string)sObj.get('Id');
        }
        else if(objName=='account'){
            sObj=(Account)obj;
            tobj.Related_Object_Name__c='Account';
            tobj.Object_Id__c=(string)sObj.get('Id');
        }
        else if(objName=='employment'){
            sObj=(Employment__c)obj;
            tobj.Related_Object_Name__c='Employment__c';
            tobj.Object_Id__c=(string)sObj.get('Contact__c');
        }
        else if(objName=='expense'){
            sObj=(Expense__c)obj;
            tobj.Related_Object_Name__c='Expense__c';
            tobj.Object_Id__c=(string)sObj.get('Contact__c');
        }
        else if(objName=='loan'){
            sObj=(Loan__c)obj;
            tobj.Related_Object_Name__c='Loan__c';
            if(sObj.get('Account__c')!=null){
                tobj.Object_Id__c=(string)sObj.get('Account__c');
            }
            else{
                tobj.Object_Id__c=(string)sObj.get('Contact__c');
            }
        }
      else if(objName=='trans'){
   IController Transloan=new LoanController();
       Loan__c tloan=new Loan__c();
       sObj=(Loan_Transaction__c)obj;
       tobj.Related_Object_Name__c='Loan_Transaction__c';
      sObj=Transloan.getById('tloan');
        if(tloan.Account__c!=null){
            tobj.Object_Id__c=tloan.Account__c;
            }
            else{
                 tobj.Object_Id__c=tloan.Contact__c;
            }
        
       } 
       
        if(objName=='employment'){
             tobj.Event_Date__c=(DateTime)sObj.get('Start_Date__c');
        }
        else if(dml=='insert'){
            tobj.Event_Date__c=(DateTime)sObj.get('CreatedDate');
        }
        else{
            tobj.Event_Date__c=(DateTime)sObj.get('LastModifiedDate');
        }
        
        tobj.Subtitle__c=sub;
        tobj.Event_Type__c=etype;
        tobj.Title__c=tit;
        tobj.Related_Id__c=(Id)sObj.get('Id');
        tobj.Related_User_Id__c=(Id)sObj.get('LastModifiedById');
		tobj.Description__c=des;
       
        return tobj;
    
    }
    
    public static string aLink(Id lid,String word){
        return '<a href="/lightning/r/'+ lid +'/view">'+ word +'</a>';
    }
    
    @AuraEnabled
    public static string getIdPrefix(){
        Schema.DescribeSObjectResult k=Application__c.sObjectType.getDescribe();
        return k.getKeyPrefix();
    }
    
    @AuraEnabled
    public static string getUserName(Id id){
        UserController userObj=new UserController();
        User userDetails= (User)userObj.getById(id); 
        return userDetails.Name;
    }
  
}

TransactionAct code:
trigger TransactionAct on Loan_Transaction__c (after insert) {
    List<Timeline_Event__c> timelineList=new List<Timeline_Event__c>();
    TimelineEventController tobj=new TimelineEventController();
    ITimelineEventController timeAssignCtrl=new TimelineEventController();
    
    
  	for( Loan_Transaction__c trans :Trigger.New){
        Timeline_Event__c tEvent=new Timeline_Event__c();
               string rtype='', subtitle='';
        
        if( Trigger.isInsert){
            

            if(trans.Type__c=='Disbursal'){
                subtitle=rtype+'Disbursal of';
      tevent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans, '', subtitle,'', '','insert','trans');

             timelineList.add(tEvent);
            }    
            else if(trans.Type__c=='Payment'){
                 subtitle=rtype+'Payment of';
    tevent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans,'', subtitle,'', '','insert','trans');

                timelineList.add(tEvent);
            }
            
            
        }
 
          }
   tobj.createMany(timelineList);  

}

There is any resolved solution.for this?
  • September 02, 2020
  • Like
  • 0
IController Transloan=new LoanController();
       Loan__c tloan=new Loan__c();
       sObj=(Loan_Transaction__c)obj;
       tobj.Related_Object_Name__c='Loan_Transaction__c';
      tloan=(Loan__c)Transloan.getById();
        if(tloan.Account__c!=null){
            tobj.Object_Id__c=tloan.Account__c;
            }
            else{
                 tobj.Object_Id__c=tloan.Contact__c;
            }
        
  • September 01, 2020
  • Like
  • 0
I have picklist field name is Type__c and in that values are Disbursal and payment, where Disbursal=1000 & Payment is =5000.
My requirement is when I choose disbursal I need a trigger and show the values of disbursal of 1000 and the same as payment need to show if I chose a payment.
This code of trigger.
trigger TransactionAct on Loan_Transaction__c (after insert) {
    List<Timeline_Event__c> timelineList=new List<Timeline_Event__c>();
    TimelineEventController tobj=new TimelineEventController();
    ITimelineEventController timeAssignCtrl=new TimelineEventController();
    IController conCtrl=new contactController();
    
  	for( Loan_Transaction__c trans :Trigger.New){
        Timeline_Event__c tEvent=new Timeline_Event__c();
               string rtype='', subtitle='';
        
        if( Trigger.isAfter){
                sObject c=conCtrl.getById(trans.Loan__c);

            if(trans.Type__c=='Disbursal'){
                subtitle=rtype+'Disbursal of';
  tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans ,'trans Disbural',subtitle,'insert','trans' );
         timelineList.add(tEvent);
            }    
            else if(trans.Type__c=='Payment'){
                 subtitle=rtype+'Payment of';
                 tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans,'trans Payment','',subtitle,'insert','tarns'  );
                 timelineList.add(tEvent);
            }
            
            
        }
 
          }
   tobj.createMany(timelineList);  

}

 
  • August 25, 2020
  • Like
  • 0
  • August 21, 2020
  • Like
  • 0
I have enabled multi-currency futures in my org but when I pull the code from my org via vs code, it throws an error no CustomField named SSR__c.CurrencyIsoCode found, (SSR is a custom object) is there is any solution there?
  • August 20, 2020
  • Like
  • 0
I'd like to display it like this: today At 5:00 PM.
User-added image
This my code 

var today = new Date();
        var date = new Date(today)
        date.setDate(date.getDate()-1)
        today.toDateString()
        date.toDateString()
        var time = today.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
        var dateTime = date+' '+time;
        this.dateTimeValue=dateTime;

 
My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
I have Loan object with three fields and look up relation with application in application object also i has same three fields ,now i need to fetch the data from apex class

 This my apex code:
public static List <SObject> chart(Id id){
    List<sObject> entities= [SELECT Total_Jobs_Created__c,Total_Jobs_Lost__c,Total_Jobs_Maintained__c, Application__r.Total_Jobs_Created__c,Application__r.Total_Jobs_Lost__c,Application__r.Total_Jobs_Maintained__c
  FROM Loan__c  WHERE Id=:id];

   return entities;
}

This my js code:
loanImpactjobs() {
          console.log("sai")
        this.loading=true;
        let loanjobs={'sobjectType':'Loan__c'};
        chart({id:this.recordId }).then(data=>{
        if(data!==''&& data!== 'null' && data!=='undefined'){  
            var jobs=JSON.parse(this.details);
            this.LCreatedjobsValue=jobs["Total_Jobs_Created__c"];
            console.log(this.LMaintainedjobsValue)
            this.LLostjobsValue=jobs["Total_Jobs_Lost__c"];
            console.log(this.LCreatedjobsValue);
            this.LMaintainedjobsValue=jobs["Total_Jobs_Maintained__c"];
            console.log(this.LLostjobsValue);
           
        }
        } ).catch(error => {
            this.errorMessage(error);
        });
    }

i used this code only ,but it doesnt worked anything ineed to chnage?
This my code i used(anything i need to modify,please let me know).
import { LightningElement, track, api,wire } from 'lwc';
import { getRecord,getFieldValue  } from 'lightning/uiRecordApi';
@track recType; 
@api recordId;
@track LjobsValue;
@track CjobsValue;
@track MjobsValue;
@wire(getRecord, { recordId: '$recordId', layoutTypes: ['Full'], modes: ['View'] })
    wiredRecord({data,error}) {
       if (data) { 
       var result = JSON.parse(JSON.stringify(data)); 
       this.recType=result.recordTypeId;
       this.LjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Lost__c');
       this.MjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Maintained__c');
       this.CjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Created__c');
       }
       else{
         this.error=error;  
         console.log(error);
       }
   }
i used this code it throws error in console

this cause error:User-added image
I have error 404  message while opening the trailhead playground 1 it showing 404 error past 1 week it showing same error ..there is any resolved solution
  • November 29, 2019
  • Like
  • 0
It is possible to create custom related to fields in lighting form or lwc possible.
I need like this in custom by using lwc or lighting record form?
User-added image
  • September 11, 2020
  • Like
  • 0
IController Transloan=new LoanController();
       Loan__c tloan=new Loan__c();
       sObj=(Loan_Transaction__c)obj;
       tobj.Related_Object_Name__c='Loan_Transaction__c';
      tloan=(Loan__c)Transloan.getById();
        if(tloan.Account__c!=null){
            tobj.Object_Id__c=tloan.Account__c;
            }
            else{
                 tobj.Object_Id__c=tloan.Contact__c;
            }
        
  • September 01, 2020
  • Like
  • 0
I have picklist field name is Type__c and in that values are Disbursal and payment, where Disbursal=1000 & Payment is =5000.
My requirement is when I choose disbursal I need a trigger and show the values of disbursal of 1000 and the same as payment need to show if I chose a payment.
This code of trigger.
trigger TransactionAct on Loan_Transaction__c (after insert) {
    List<Timeline_Event__c> timelineList=new List<Timeline_Event__c>();
    TimelineEventController tobj=new TimelineEventController();
    ITimelineEventController timeAssignCtrl=new TimelineEventController();
    IController conCtrl=new contactController();
    
  	for( Loan_Transaction__c trans :Trigger.New){
        Timeline_Event__c tEvent=new Timeline_Event__c();
               string rtype='', subtitle='';
        
        if( Trigger.isAfter){
                sObject c=conCtrl.getById(trans.Loan__c);

            if(trans.Type__c=='Disbursal'){
                subtitle=rtype+'Disbursal of';
  tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans ,'trans Disbural',subtitle,'insert','trans' );
         timelineList.add(tEvent);
            }    
            else if(trans.Type__c=='Payment'){
                 subtitle=rtype+'Payment of';
                 tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans,'trans Payment','',subtitle,'insert','tarns'  );
                 timelineList.add(tEvent);
            }
            
            
        }
 
          }
   tobj.createMany(timelineList);  

}

 
  • August 25, 2020
  • Like
  • 0
My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
I have Loan object with three fields and look up relation with application in application object also i has same three fields ,now i need to fetch the data from apex class

 This my apex code:
public static List <SObject> chart(Id id){
    List<sObject> entities= [SELECT Total_Jobs_Created__c,Total_Jobs_Lost__c,Total_Jobs_Maintained__c, Application__r.Total_Jobs_Created__c,Application__r.Total_Jobs_Lost__c,Application__r.Total_Jobs_Maintained__c
  FROM Loan__c  WHERE Id=:id];

   return entities;
}

This my js code:
loanImpactjobs() {
          console.log("sai")
        this.loading=true;
        let loanjobs={'sobjectType':'Loan__c'};
        chart({id:this.recordId }).then(data=>{
        if(data!==''&& data!== 'null' && data!=='undefined'){  
            var jobs=JSON.parse(this.details);
            this.LCreatedjobsValue=jobs["Total_Jobs_Created__c"];
            console.log(this.LMaintainedjobsValue)
            this.LLostjobsValue=jobs["Total_Jobs_Lost__c"];
            console.log(this.LCreatedjobsValue);
            this.LMaintainedjobsValue=jobs["Total_Jobs_Maintained__c"];
            console.log(this.LLostjobsValue);
           
        }
        } ).catch(error => {
            this.errorMessage(error);
        });
    }

i used this code only ,but it doesnt worked anything ineed to chnage?
This my code i used(anything i need to modify,please let me know).
import { LightningElement, track, api,wire } from 'lwc';
import { getRecord,getFieldValue  } from 'lightning/uiRecordApi';
@track recType; 
@api recordId;
@track LjobsValue;
@track CjobsValue;
@track MjobsValue;
@wire(getRecord, { recordId: '$recordId', layoutTypes: ['Full'], modes: ['View'] })
    wiredRecord({data,error}) {
       if (data) { 
       var result = JSON.parse(JSON.stringify(data)); 
       this.recType=result.recordTypeId;
       this.LjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Lost__c');
       this.MjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Maintained__c');
       this.CjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Created__c');
       }
       else{
         this.error=error;  
         console.log(error);
       }
   }
i used this code it throws error in console

this cause error:User-added image