• Michaela Chrysostomou
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 9
    Replies
While cloning a record, is it possible to copy only certain field values. I want some fields to be empty whichmeans it should not contain the existing value. In the classic we did this by passing parameters in the URL. How we can do this in Lightning now? 

Please help me. 
We have few applications on Classic and few on Lightning.
We need somehow if a user is working on Classic and from the App menu chooses a Lightning App automatically to navigate to the Lightning App and the other way around.

We tried to create a connected app and specify the URL of the Tab.
This seems to not work as always opens as a sub-tab of the last opened App in Lighting.

Is there any way to resolve this ? Right now the user experience is complicate as now they have to remember to switch between classic and Lightning to access a specific Application.

I've contacted Salesforce and they said that this can be resolved with Apex code. Can anyone have an idea how can we do this ?
Controller
public class FlowController {
 public Flow.Interview.Computer_Forms theFlow {get; set;}
 public PageReference getNewDispatchRecord(){
 if(theFlow == null)
return null;
else if(theflow.neorecord!=null)
return new PageReference('/' + theFlow.neorecord);
else
return new PageReference('/a28');
}
}

Test Class


@isTest 
private class FlowControllerTest {
   public static testMethod void myTestMethodForFlow() {
                  FlowController aFlowController = new FlowController();       
        aFlowController.theFlow= new Flow.Interview.Computer_Forms (new Map<String, Object>());
               PageReference pageRef = Page.VF_for_flow_in_CF;
                  Test.setCurrentPage(pageRef);
       string neorecord='a28550000001jch';
       string OwnerId='00516000006jIub';
       string Type='Desktop';
       string workload='Normal';
       string Reason='New';
       string OS_choice='Aple';
       
        }
        }


I get code covarage 14%. Any help?
While cloning a record, is it possible to copy only certain field values. I want some fields to be empty whichmeans it should not contain the existing value. In the classic we did this by passing parameters in the URL. How we can do this in Lightning now? 

Please help me. 
Controller
public class FlowController {
 public Flow.Interview.Computer_Forms theFlow {get; set;}
 public PageReference getNewDispatchRecord(){
 if(theFlow == null)
return null;
else if(theflow.neorecord!=null)
return new PageReference('/' + theFlow.neorecord);
else
return new PageReference('/a28');
}
}

Test Class


@isTest 
private class FlowControllerTest {
   public static testMethod void myTestMethodForFlow() {
                  FlowController aFlowController = new FlowController();       
        aFlowController.theFlow= new Flow.Interview.Computer_Forms (new Map<String, Object>());
               PageReference pageRef = Page.VF_for_flow_in_CF;
                  Test.setCurrentPage(pageRef);
       string neorecord='a28550000001jch';
       string OwnerId='00516000006jIub';
       string Type='Desktop';
       string workload='Normal';
       string Reason='New';
       string OS_choice='Aple';
       
        }
        }


I get code covarage 14%. Any help?
I am creating a new record using Screen/Create Record elements of a Flow. I am starting that Flow with a customized New button. I am now attempting to make the FinishLocation as the newly created record. Here is the VF page which I am referring to with the New button in order to kick off the Flow : 
 
<apex:page standardcontroller="Vendor_Profile__c" Extensions="New_Vendor_With_Flow_Controller2">
<flow:interview name="New_Vendor_Profile"/>
</apex:page>

and the class which is the Extension is this :
 
public class New_Vendor_With_Flow_Controller2 {

    public New_Vendor_With_Flow_Controller2(ApexPages.StandardController controller) {

    }


public flow.interview.New_Vendor_Profile myFlow {get;set;}

    public New_Vendor_With_Flow_Controller2() {
    }
    
    public String getendID() {
        
        if (myFlow !=null) return myFlow.VarRecordID;
        else return 'home/home.jsp';
        }
       
    public PageReference getFinishLocation() {
        System.debug('VarRecordID ########'+myFlow.VarRecordID); 
        PageReference endlocation = new PageReference('/' + getendID());
        return endlocation;
        }
}


I am attempting to use the VarRecordID variable which I set in the Create Record element in the Page Reference. 

I don't think I need to set a FinishLocation in the VF page, do I ? If I set that it will only go to that spot at the end of the Flow. I don't think I can refer to the VarRecordID variable in the FinishLocation so I didn't set one. 

Anyone have any suggestions on this ?
 

  • October 16, 2015
  • Like
  • 0
hi,
I have a VF Page it contains search input search box and search button.If i entered any value in search text box like "Car" it should redirect from VF page to the google search page with keyword name and displays results regarding cars. 

Is it possible using VF page.
Please suggest me how to approach...

Thank you.
 
I created the following Apex Class and Apex Trigger. However the code coverage for the Apex Class is only 63% and the Aoex Trigger is 0%.

How do I increase the code coverage for the Apex Class and Apex Trigger?

Apex Class: ApprovedSFDCRequestPDF
Code Coverage: 63% (13/19)
public class ApprovedSFDCRequestPDF
{
    public SFDC__c SFDCReq;
    //public DateTime craDateTime = DateTime.now();
    private ApexPages.StandardController stdController;
    
    public ApprovedSFDCRequestPDF(ApexPages.StandardController stdController)
    {
        this.stdController = stdController;
        SFDCReq = (SFDC__c)stdController.getRecord();
    } 
    // Attach Approved SFDC Request to current SFDC__c 
    
    public PageReference attach()
    {
        DateTime craDateTime = DateTime.now();
        SFDC__c  f=[select id,name,Submitted_for_Approval__c,SFDC_Request_Status__c from SFDC__c where id=:SFDCReq.id];
        if(f.Submitted_for_Approval__c==True&&f.SFDC_Request_Status__c=='Approved')
        {
            // Get the page definition 
            //PageReference pdfPage = Page.ApprovedSFDCRequestPDF;   
            
            PageReference pdfPage = new PageReference('/apex/ApprovedSFDCRequestPDF?id=' + SFDCReq.id);
           
            
            //pdfPage.getParameters().put('id',SFDCReq.id);
             Blob pdfBlob = null;
            // Generate the pdf blob
            if(!Test.isRunningTest())//added by Najma for #00055992
             pdfBlob = pdfPage.getContent();
            else
            pdfBlob = Blob.valueOf('Test');
            //SFDC__c f=[select id,name from SFDC__c where id=:SFDCReq.id];
            // Create the attachment against the Approved SFDC Request page 
            Attachment a = new Attachment(parentId = f.id, name=f.name + ' - SFDC ' + craDateTime.formatlong() + '.pdf', body = pdfBlob);
            // Insert the attachment into the SFDC Request
            
            insert a;
        }
        PageReference p=new PageReference('/'+f.id);
        p.setredirect(true);
        return p;  
    }
}

Apex Trigger:  CreateSFDCRequestTrigger
Code Coverage: 0% (0/3)
trigger CreateSFDCRequestTrigger on SFDC__c (before update) {
     for(SFDC__c  sfdc : trigger.new){
        if(sfdc.FromApprovalProcess__c == true ){
             GenerateCDRPDF.generateCDRPDFAttachment(sfdc.id, 'sfdc', UserInfo.getSessionId());
        }
    }
}

Thanks!

Beth
I'm new to VF development. I'm trying to create a button that makes a new opportunity from an existing opportunity and uses some of the values from the old opportunity and changes others. Similar to a clone button but with control over what goes into each field.

I'm using a controller extension for this operation.

I've seen 2 examples of how to get the Id of the current record I'm starting with and I'm trying to determine method is best (or at least the pros/cons of each).  Both methods are in the controller constructor.

Method #1: Using controller.getRecord()
public class myExtension {

    Opportunity currentRecord;
    
    public myExtension(ApexPages.StandardController controller) {
        this.currentRecord = (Opportunity)controller.getRecord();
        currentRecord = [SELECT Id, Name, Amount FROM Opportunity WHERE Id = :currentRecord.Id];
    }

    public Opportunity getcurrentRecord(){
        return currentRecord;
    }
}

Method #2: using Page Parameters
public class myExtension {

    Opportunity currentRecord;
    
    public myExtension(ApexPages.StandardController controller) {
        currentRecord = [SELECT Id, Name, Amount FROM Opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Opportunity getcurrentRecord(){
        return currentRecord;
    }
}

Alternatively, if there is another method better than either of these, please let me know.
I have a javascript button I am trying to create to update a picklist field on a custom object.  Here is the code for the button:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var p = new sforce.SObject('Projects__c');
p.id = "{Projects__c.Id}";
p.Status__c = "Closed";
result = sforce.connection.update([p]);
location.reload(true);

The code is not throwing errors on the object it is just not updating the field.  The page is reloading. Anything wrong with the code?

  • January 06, 2014
  • Like
  • 2

Hi,

 I want to display an image from attached file on vf page.

 

//vf

<apex:page standardController="stdCust_obj__c" extensions="displayImageExtension">
<table><tr>
<td><h1>Photo:</h1></td>
<td>
<apex:image url="/servlet/servlet.FileDownload?file=file.Id"/>
</td>
</tr>
</table>
</apex:page>

 

//apex

 

public class displayImageExtension {

private id StCustId;
List<Attachment> file;

 

public displayImageExtension(ApexPages.StandardController stdController) {
this.StCustId = ApexPages.currentPage().getParameters().get('id');
}

public List<Attachment> getfile(){

file=[Select Id,Name,LastModifiedDate from attachment where ParentId=:StCustId];
return file; 
}

 

}

 

Thanks in advance.

  • July 20, 2013
  • Like
  • 0

I've built a Flow that creates a new record for a Custom object. I'm setting a variable to the new id in the Flow, but I think my VF page is reading its value at creation, which is null. How do I set a page reference to the new id so I can redirect to the new Dispatch__c object? 

 

Controller:

public class DispatchFlowController {
	
	public Flow.Interview.New_Dispatch_Flow theFlow {get; set;}
		
	public PageReference getNewDispatchRecord(){
		if(theFlow == null)
			return null;
		else
			return new PageReference('/' + theFlow.NewDispatchId);
	}
	
}

 VF Page:

<apex:page Controller="DispatchFlowController" >
<flow:interview name="New_Dispatch_Flow" interview="{!theFlow}" 
	finishLocation="{!NewDispatchRecord}"/>
</apex:page>

 note, if I hard-code the new PageReference to an existing id it does redirect to that object instance, but obviously I don't know what id my new object will have until the end of the Flow.

I've built a Flow that creates a new record for a Custom object. I'm setting a variable to the new id in the Flow, but I think my VF page is reading its value at creation, which is null. How do I set a page reference to the new id so I can redirect to the new Dispatch__c object? 

 

Controller:

public class DispatchFlowController {
	
	public Flow.Interview.New_Dispatch_Flow theFlow {get; set;}
		
	public PageReference getNewDispatchRecord(){
		if(theFlow == null)
			return null;
		else
			return new PageReference('/' + theFlow.NewDispatchId);
	}
	
}

 VF Page:

<apex:page Controller="DispatchFlowController" >
<flow:interview name="New_Dispatch_Flow" interview="{!theFlow}" 
	finishLocation="{!NewDispatchRecord}"/>
</apex:page>

 note, if I hard-code the new PageReference to an existing id it does redirect to that object instance, but obviously I don't know what id my new object will have until the end of the Flow.