• Adarsh.Sharma
  • NEWBIE
  • 182 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 36
    Replies
I have the following Apex class that is only getting 57% code coverage.  Test class below as well. I feel like there is something simple that I'm missing. Any help would be appreciated!

public class taskController{

    public Project_Task__c task{get;set;}
    public List<Project_Task_Assignment__c> assignment{get;set;}
    public taskController(){
        task = new Project_Task__c();
        assignment = new List<Project_Task_Assignment__c>();
        task.Project__c = ApexPages.currentPage().getParameters().get('Id');
     
    }
    public void AddRow(){
        assignment.add(new Project_Task_Assignment__c());
    
    }
    public PageReference save(){

     try{
            insert task;
            List<Project_Task_Assignment__c> taskAssignment = new List<Project_Task_Assignment__c>();
            for(Project_Task_Assignment__c c : assignment){
                c.Project_Task__c = task.id;
                taskAssignment.add(c);
    
            }

            if(assignment != null){
                insert taskAssignment;
           }
           
            PageReference taskPage = new PageReference('/apex/manage_task?id=' + task.id);
        taskPage.setRedirect(true);
        return taskPage;
      } 
      
     catch (Exception e) {apexpages.addmessages(e);}return null;        
      
  }  
    
}

*****Test Class*****
@isTest
    public class taskControllerTest{
         private static testMethod void saveTask() {
        
         Account acc = new Account(Name = 'Sample Account'); insert acc;
         Contact con = new Contact(LastName = 'Smith', AccountId = acc.id); insert con;    
         Plan__c plan = new Plan__c(Name = 'Test'); insert plan;
         Project__c project = new Project__c(Name = 'Test', Plan__c = plan.id); insert project;
         
    
            
    
         Test.startTest();
         
         PageReference pageRef = Page.AccountContact;
         
         Project_Task__c task = new Project_Task__c(Project__c = project.id, Name = 'Test Task'); 
         insert task;
         Project_Task_Assignment__c assignment = new Project_Task_Assignment__c(Project_Task__c = task.id, Contact__c = con.id);
         insert assignment;
         Test.setCurrentPage(pageRef);
         taskController controller = new taskController();
         controller.addRow();       

         controller.save();
         pageRef.getParameters().put('id',task.id);   

         Test.stopTest();        
         
         System.assertNotEquals(task.Name, null);
         System.assertNotEquals(assignment, null);         
    
   } 
             
}
Knowledge Folder Tree from Setup
Please can someone help? I would like to finish the knowledge challenge to back up my learning for advanced admin exam, however article types is missing. Please let me know what I need to do. I have activated the licences etc.
Thanks
Hi,
I have created a Component page on that page, I have create a next button, now I want when I press next button it will we call another component page .

Thanks, 
Sumit
Hi all, Any hints on how to Log a Case for Extended Mail Merge features in developer org?
Any way to enable this features in developer org Mail Merge Template.
I have the following Apex class that is only getting 57% code coverage.  Test class below as well. I feel like there is something simple that I'm missing. Any help would be appreciated!

public class taskController{

    public Project_Task__c task{get;set;}
    public List<Project_Task_Assignment__c> assignment{get;set;}
    public taskController(){
        task = new Project_Task__c();
        assignment = new List<Project_Task_Assignment__c>();
        task.Project__c = ApexPages.currentPage().getParameters().get('Id');
     
    }
    public void AddRow(){
        assignment.add(new Project_Task_Assignment__c());
    
    }
    public PageReference save(){

     try{
            insert task;
            List<Project_Task_Assignment__c> taskAssignment = new List<Project_Task_Assignment__c>();
            for(Project_Task_Assignment__c c : assignment){
                c.Project_Task__c = task.id;
                taskAssignment.add(c);
    
            }

            if(assignment != null){
                insert taskAssignment;
           }
           
            PageReference taskPage = new PageReference('/apex/manage_task?id=' + task.id);
        taskPage.setRedirect(true);
        return taskPage;
      } 
      
     catch (Exception e) {apexpages.addmessages(e);}return null;        
      
  }  
    
}

*****Test Class*****
@isTest
    public class taskControllerTest{
         private static testMethod void saveTask() {
        
         Account acc = new Account(Name = 'Sample Account'); insert acc;
         Contact con = new Contact(LastName = 'Smith', AccountId = acc.id); insert con;    
         Plan__c plan = new Plan__c(Name = 'Test'); insert plan;
         Project__c project = new Project__c(Name = 'Test', Plan__c = plan.id); insert project;
         
    
            
    
         Test.startTest();
         
         PageReference pageRef = Page.AccountContact;
         
         Project_Task__c task = new Project_Task__c(Project__c = project.id, Name = 'Test Task'); 
         insert task;
         Project_Task_Assignment__c assignment = new Project_Task_Assignment__c(Project_Task__c = task.id, Contact__c = con.id);
         insert assignment;
         Test.setCurrentPage(pageRef);
         taskController controller = new taskController();
         controller.addRow();       

         controller.save();
         pageRef.getParameters().put('id',task.id);   

         Test.stopTest();        
         
         System.assertNotEquals(task.Name, null);
         System.assertNotEquals(assignment, null);         
    
   } 
             
}
public without sharing class CreateContactController {

    @AuraEnabled
    public static Id createRecord (Contact contact){
        System.debug('Inserting contact with:' + contact.FirstName + contact.LastName + contact.Email);
        Id returnID = null;        
        if(contact != null){
      User u = [SELECT Id, Contact.AccountId FROM User WHERE Id = :UserInfo.getUserId()][0];
            contact.AccountId = u.Contact.AccountId;
            insert contact;
            returnId = contact.Id;
        }
        else {
            System.debug('Could not insert.');
        }
        return returnId;
    }

}
Hi Folks, 
I need to export Salesforce Data to FTP Server in Schedule and Real time manner. 
But except Dataloader.io.
Please advise

Thanks.
  • February 16, 2018
  • Like
  • 0
COuld someone please help me with a trigger on account object and populate owner name in any custom field.
Hello community,

Please help me!
I´ve completed the Challenge and I´ve earned +500 points but I don´t find the custom button.

I´ve configured the button as follows:

User-added image

And I´ve configured the Page Layout as follows:

User-added image

And earned 100% points:

User-added image

I´ve checked the Page Layout Assignment and everything seems good:

User-added image

But I don´t find the button Google Info in the actions menu as described in the lecture:

User-added image

Has someone had the same issue?
 
<apex:page controller="dynamicObjectRecord_cntlr" >
    <apex:form >
        <apex:pageBlock title="Dynamic Object and it's Records">
            <apex:pageBlockSection title="SeleObject Information">
                <apex:inputText label="Object Name:" value="{!sobj}"/>
                <apex:commandButton value="Search" action="{!search}"/>
            </apex:pageBlockSection>
        
            <apex:pageBlockSection title="Records of {!sobj}">
                <apex:pageBlockTable value="{!listRec}" var="a">
                    <apex:column headerValue="ID" value="{!a.id}"/>
                    <apex:column headerValue="Name" value="{!a.name}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


------------------------

public class dynamicObjectRecord_cntlr {
    Public sobject obj {get;set;}
    public String sobj { get; set; }
    public Map<string,Schema.sobjectType> mobj;
    public Set<String> s_allObj;
    public List<String> l_allObj;
    public List<sObject> listRec {get;set;} 
    public Boolean Opresent;
    
    public dynamicObjectRecord_cntlr ()
    {     obj = null;
        sobj= null;
        mobj = new Map<String,Schema.sobjectType>();
        s_allObj = new Set<String>();
         l_allObj = new List<String>();
         Opresent = false;
         listRec = new List<sobject>();
    }
    
     public PageReference search() {
        mobj= Schema.getGlobalDescribe();
        s_allobj = mobj.keySet(); 
        l_allObj.addAll(s_allobj);
         
         System.debug('Selected value is --'+sobj);
        for(String s:l_allObj)
        {
            if(s==sobj){
                Opresent=true;
                break;
            }
        }
        
         if(Opresent==true)
         {
             String query = 'SELECT id,Name from '+sobj +' LIMIT 50';
             System.debug('Query written is '+query);
             ListRec = Database.query(query);
             System.debug('List of Rec'+ListRec);
         }
        return null;
    }

}
Knowledge Folder Tree from Setup
Please can someone help? I would like to finish the knowledge challenge to back up my learning for advanced admin exam, however article types is missing. Please let me know what I need to do. I have activated the licences etc.
Thanks
Dear All,

Here i have the requirement to use FTP server in salesforce..

-- we have one external system and data inserted into it day by day
-- after that at the end of the day one file(.csv) automatically generated to that external system
-- How can i access of that file(.csv) from external system in salesforce using FTP server
-- after having that file's data i need to insert that data automatically(scheduled) in salesforce which is coming from external system

How can i achieve this ?

Please suggest the way..

Thanks
-Nihar
Can any one help me how to Transfer files to FTP from Salesforce Attachment object.
 
Hi All

Can any body tell me how to connect FTP server to SFDC Organization using integration
Hi,
I have an task in which we have to integrate with the intranet ftp server. so we can store and retrive the data files from ftp server.

Does any one have any idea regarding the same. How can we ingrate the salesforce org with ftp server. 

Any  help will be appreciated. 

Thanks to all in advance :)

I am pretty sure Salesforce doesn't support this in Apex -or does it?! If not then does that mean I have to use the Streaming API? But that would involve Visualforce, and I'm hoping to find a solution only in Apex.

 

Thanks!

Hi,

 

I have a requirement to post  some data from SFDC to Secure FTP Server. if anybody have the idea about this please let me know.

 

Thanks In Advance

 

regards

Somes

Hello,

 

Not sure this is the right forum for this topic, if not please kindly suggest alternative forum.

 

Looking for information on how to setup the mechanism to pull/decrypt and load in Salesforce objects encrypted CSV files containing customers information and hosted on SFTP server. 

 

Would be glad to receive suggections on recommended procedures, tools and best practices.

 

Thanks,

S

 

 

 

 

Hello Friends,

 

I have a requirement wherein the users will click on a button and a CSV file should be generated with some data. Now this file should be automatically sent to an FTP server in real time.

 

Can this be achieved in salesforce by any means?

 

Please Help!

Cool_D