• Kristiana Granger
  • NEWBIE
  • 70 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 13
    Replies
For example - If file extension is [pdf, docx, png] and size is certain it should allow to upload. When I write trigger on contentDocument it seems its not working correctly, can any one please guide 
I have below requirment - 
Train and Coach are 2 objects. Where I need to build logic based on train schedule and availibility. From UI side admin can add the coach to the train. 

Train (Parent Object - From, To, Timings)
Coach (Child Object - From, To, Timings) Field is there. 

Now from UI side when user book the tickets. based on given 3 fields I need to add coachs in the train. lets say next week on monday there will 3 trains are schedule from X to Y location. now today we see many passanger book the train from X to Y location. so basically, based on timings I need to add number of coaches in next week train so I can accomodate all customers. Its not like 1 train run with 5-6 coach, while other train runs with 30-35 coach. there has to balance. 

Please let me know if need further clarification in scenario. 
Hi, All
I am new to salesforce, can anyone help me to get 100% coverage please 


public class MyContactListController 
{
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) 
    {
        List<Contact> conList = new List<Contact>();
        try{
            System.debug('--'+recordId);
            conList = [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
            System.debug('conlist result----> '+conList);
        }
        catch(Exception e){
            System.debug('inside catch Block  -> '+e.getMessage());
        }
        return conList;
    }
}



-----------------------------------------
TestClass
-----------------------------------------
@isTest
public class MyContactListControllerTest {
   
    static testMethod void getContactsTest(){
        Account ac = new Account(Name='Name1');
        Insert ac;
        List<Account> acList = [select id, name from Account where id!=NULL];
        System.assertEquals(true,acList.size()>0);
        MyContactListController.getContacts(acList[0].id);
        List<Case> case_Obj  =  [SELECT Id,CaseNumber,AccountId From Case WHERE AccountId=:acList[0].Id LIMIT 10];
       
        MyContactListController.getContacts(acList[0].Id); 
      
    }
}
On user object - I want to display warning message via VF page, but here the problem is there is no option for Inline VF page on User Layout. is there any workaround?
OR
Apart from VF page is there any other options to display warning?
User object there is no option for Inline VF page

My requirment is - Junction Object (Junction1__c) record should get created when user create new record on "Account"/"Location" object

Data model -
Account Obj 
M_number__c field

Location object
M_number__c field


Junction1 Object
Account__c (M-D Rel with Account)
location__c (M-D rel with location)

When user create new recrod on Account Or Location object, it should automatically create new Rec on Junction Obj
Can any one share some related URL's
Via Azure or any medium how can I deploy my entire repo
Parent Object - AC - field1 Status picklist value 
Child Object Op - When Field1 is "Completed" it should not allowed to create OP record. 

 
Can anyone guide me how to write Validation rule, When Field status is Complete / cancelled at that time child object should not allowed be created
Here is code 
 public static List<RetentionPlan__mdt> fetchAllData() {
        List<RetentionPlan__mdt> dataList = [Select id, Order__c , 
                                                       Retain__c, Limit__c,
                                                      SobjectAPIName__c ,                                                     SobjectAPIName__r.QualifiedApiName,
                                                       Where__c 
                                                       FROM RetentionPlan__mdt 
                                                    WHERE isActive__c = true];

        return dataList;   
    }
    
   public static void operationDataStorageReduction(List<sobject> scope) {
        Database.delete(scope, false);
    }
---------------------------
So basicaly these two methods get call from batch class, (Delete records) Can any one guide me how to write testclass for these 2
Account and Contact One Custom fiedl - "Status"
one Account having multiple contact - if all contact Status fiedl is Active then only update "Active" in Account page. Even if 1 contact inactive then Account also inactive - 
I have written trigger. but it working fine only with 1 record. I mean when user insert new contatc at that whatever status I have given based on that it update on contact. but how to check for All contact ? 
A developer creates a Workflow Rule declaratively that updates a field on an object. An Apex update trigger exists for that object.
What happens when a user updates a record?  

A. No changes are made to the data.
B. Both the Apex Trigger and Workflow Rule are fired only once.
C. The Workflow Rule is fired more than once.
D. The Apex Trigger is fired more than once

Ex - There is one button(action) we have created.

when user clicked that button from LE so it should open view in Lightning ,
when user clicked from classic it should open in classic view
when user clicked from salesforce1 it should be open in respective view.
based on which things we can come to know. can any one gives me sample code ?


 

Hi, All
I am new to salesforce, can anyone help me to get 100% coverage please 


public class MyContactListController 
{
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) 
    {
        List<Contact> conList = new List<Contact>();
        try{
            System.debug('--'+recordId);
            conList = [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
            System.debug('conlist result----> '+conList);
        }
        catch(Exception e){
            System.debug('inside catch Block  -> '+e.getMessage());
        }
        return conList;
    }
}



-----------------------------------------
TestClass
-----------------------------------------
@isTest
public class MyContactListControllerTest {
   
    static testMethod void getContactsTest(){
        Account ac = new Account(Name='Name1');
        Insert ac;
        List<Account> acList = [select id, name from Account where id!=NULL];
        System.assertEquals(true,acList.size()>0);
        MyContactListController.getContacts(acList[0].id);
        List<Case> case_Obj  =  [SELECT Id,CaseNumber,AccountId From Case WHERE AccountId=:acList[0].Id LIMIT 10];
       
        MyContactListController.getContacts(acList[0].Id); 
      
    }
}
For example - If file extension is [pdf, docx, png] and size is certain it should allow to upload. When I write trigger on contentDocument it seems its not working correctly, can any one please guide 
Hi, All
I am new to salesforce, can anyone help me to get 100% coverage please 


public class MyContactListController 
{
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) 
    {
        List<Contact> conList = new List<Contact>();
        try{
            System.debug('--'+recordId);
            conList = [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
            System.debug('conlist result----> '+conList);
        }
        catch(Exception e){
            System.debug('inside catch Block  -> '+e.getMessage());
        }
        return conList;
    }
}



-----------------------------------------
TestClass
-----------------------------------------
@isTest
public class MyContactListControllerTest {
   
    static testMethod void getContactsTest(){
        Account ac = new Account(Name='Name1');
        Insert ac;
        List<Account> acList = [select id, name from Account where id!=NULL];
        System.assertEquals(true,acList.size()>0);
        MyContactListController.getContacts(acList[0].id);
        List<Case> case_Obj  =  [SELECT Id,CaseNumber,AccountId From Case WHERE AccountId=:acList[0].Id LIMIT 10];
       
        MyContactListController.getContacts(acList[0].Id); 
      
    }
}
On user object - I want to display warning message via VF page, but here the problem is there is no option for Inline VF page on User Layout. is there any workaround?
OR
Apart from VF page is there any other options to display warning?
User object there is no option for Inline VF page
i have two master detail object Author__c and Research_Paper__c and one junction object Author-Research_paper__c. Junction object has lookup field Author and Research-paper.. Now i want that after selecting Author name  from Lookup field, author name should be updated automatically in "Name of Author" in Research-paper__c object.
Here is my code:
trigger SampleAuthorPopulate on Author_Research_Paper__c (after insert,after update) {

    set<id> setid=new set<id>();
    set<id> setauthor=new set<id>();
   for(Author_Research_Paper__c ar:trigger.new)
    {
       
        setid.add(ar.Research_Paper__c);
        setauthor.add(ar.Author__c);
    }
     map<id,Research_Paper__c> rmap=new map<id,Research_Paper__c>();
    for(Research_Paper__c rc:[select id,Name_of_Primary_Author__c from Research_Paper__c where id in:setid])
    {
        rmap.put(rc.Id, rc);
    }
    
     list<Author_c> au=[select id,name from Author__c where name in: setauthor];
    list<Research_Paper__c> rlist=new  list<Research_Paper__c>();
    for(Author_Research_Paper__c ar:trigger.new)
    {
       if(rmap.containsKey(ar.Research_Paper__c))
            {
                 if(ar.Is_Primary_Author__c==true)
                {
                  
                 rmap.get(ar.Research_Paper__c).Name_of_Primary_Author__c=au.Name;
                rlist.add(rmap.get(ar.Research_Paper__c));
                }
               
            }
    }
   update rlist;
}
Parent Object - AC - field1 Status picklist value 
Child Object Op - When Field1 is "Completed" it should not allowed to create OP record. 

 
Account and Contact One Custom fiedl - "Status"
one Account having multiple contact - if all contact Status fiedl is Active then only update "Active" in Account page. Even if 1 contact inactive then Account also inactive - 
I have written trigger. but it working fine only with 1 record. I mean when user insert new contatc at that whatever status I have given based on that it update on contact. but how to check for All contact ?