function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Violeta Grigorova 3Violeta Grigorova 3 

I have developed a VisualForce page on one staging sandbox. I would like to make a package of it and deploy it on another staging sandbox. What would be a procedure I must follow?

I have developed a VisualForce page on one staging sandbox. I would like to make a package of it and deploy it on another staging sandbox. What would be a procedure I must follow?

Thank you
Best Answer chosen by Violeta Grigorova 3
bhanu_prakashbhanu_prakash
Hi Violeta,

check out below link
https://help.salesforce.com/articleView?id=creating_packages.htm&type=5
Note: While adding VisualForce Page into Package if you used any class, controller need to be added into package too ..

let us know if it helps you and mark it best if it helps you :) :) 
Thanks, 
Bhanu Prakash
visit ForceLearn (https://www.forcelearn.com)for salesforce Latest Updates and development tips

 

All Answers

bhanu_prakashbhanu_prakash
Hi Violeta,

check out below link
https://help.salesforce.com/articleView?id=creating_packages.htm&type=5
Note: While adding VisualForce Page into Package if you used any class, controller need to be added into package too ..

let us know if it helps you and mark it best if it helps you :) :) 
Thanks, 
Bhanu Prakash
visit ForceLearn (https://www.forcelearn.com)for salesforce Latest Updates and development tips

 
This was selected as the best answer
Violeta Grigorova 3Violeta Grigorova 3
Hi, @bhanu_prakash. I read the link. It seems that there are two types of packages - managed and unmanaged I have to make a package for internal use within our organisation. Would the Unmanaged package be sufficient?

Thank you
bhanu_prakashbhanu_prakash
Hi Violeta,

My Suggestion is Go for Unmanaged package it helps developers to enchance code as per business logic. 
If you use Managed Package the code will be hidden and enchancment is not possible on further.

let us know if it helps you and mark it best if it helps you :) :) 
Thanks, 
Bhanu Prakash
visit ForceLearn (https://www.forcelearn.com)for salesforce Latest Updates and development tips
Violeta Grigorova 3Violeta Grigorova 3
Bhanu,

thank you very much!

Apparently, you have to have >75% code coverage in order to b able to upload a package. Right now we have 74%. I have to therefore write a test class for my controller. Can you help in writing this. Here is the class:
 
public with sharing class ActiveSubscriptionsController {
    
    private ApexPages.StandardController stdController;
    private final Account acct;
	
   	public boolean show{get;set;}
    public boolean hide{get;set;}
   	public String DeviceId{get;set;}
    public String ContractNumber{get;set;}
    public String AccountNumber{get;set;}
    
    public ActiveSubscriptionsController(ApexPages.StandardController stdController) {
		this.stdController = stdController;
        this.acct = (Account)stdController.getRecord();
        AccountNumber = acct.AccountNumber;
        system.debug('Inside InvokeShow, AccountNumber: ' + AccountNumber);   
        show=true;
        hide=false;
    }

    public void InvokeShow(){
        show=false;
        hide=true;
		system.debug('Inside InvokeShow, DeviceId: ' + DeviceId);  
        system.debug('Inside InvokeShow, ContractNumber: ' + ContractNumber);
    }

    public void Invokehide(){
		show=true;
		hide=false;
    }
    
    public List<SBQQ__Subscription__c> getSubscriptions_front() {
        String AccountNumber = acct.AccountNumber;
        AccountNumber = AccountNumber + '%';
        String Empty = '';
        String AzureSubscription = '%Azure Subscription%';
        List<SBQQ__Subscription__c> subscriptionResults_front = 
        Database.query('SELECT Name, MasterDeviceName__c, SBQQ__ProductName__c, Location__c, DeviceId__c, SBQQ__ContractNumber__c, Server_Status__c  FROM SBQQ__Subscription__c WHERE DeviceId__c LIKE :AccountNumber AND (Location__c != :Empty OR SBQQ__ProductName__c LIKE :AzureSubscription)');
        return subscriptionResults_front;
    }
    
    public List<SBQQ__Subscription__c> getSubscriptions_filtered() {
        String Empty = '';
        List<SBQQ__Subscription__c> subscriptionResults_filtered = 
        Database.query('SELECT Name, SBQQ__ProductName__c, Location__c, DeviceId__c, SBQQ__ContractNumber__c, SBQQ__Contract__c, SBQQ__Account__c, SBQQ__RequiredByProduct__c, SBQQ__Product__c, SBQQ__ProductOption__c, SBQQ__OptionType__c, SBQQ__OrderProduct__c FROM SBQQ__Subscription__c WHERE DeviceId__c = : DeviceId AND SBQQ__ContractNumber__c  =: ContractNumber AND Location__c != :Empty');
        return subscriptionResults_filtered;
    }

    public List<SBQQ__Subscription__c> getSubscriptions_table() {
        String Empty = '';
        List<SBQQ__Subscription__c> subscriptionResults_table = 
        Database.query(
        'SELECT Name, DeviceId__c, SBQQ__ProductName__c, SBQQ__SpecialPrice__c, SBQQ__NetPrice__c, SBQQ__ProductOption__r.SBQQ__OptionalSKU__c, SBQQ__ProductOption__r.SBQQ__Selected__c, SBQQ__ProductOption__r.SBQQ__QuantityEditable__c, SBQQ__ProductOption__r.SBQQ__Quantity__c, SBQQ__ProductOption__r.SBQQ__MinQuantity__c, SBQQ__ProductOption__r.SBQQ__MaxQuantity__c, SBQQ__ProductOption__r.SBQQ__Number__c, SBQQ__ProductOption__r.ProductCategory__c,SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c FROM SBQQ__Subscription__c WHERE DeviceId__c = : DeviceId AND SBQQ__ContractNumber__c  =: ContractNumber AND Location__c = :Empty ORDER BY SBQQ__ProductOption__r.SBQQ__Number__c');
        return subscriptionResults_table;
    }
    
    public Map<String, Map<String,List <SBQQ__Subscription__c>>> getMyMap () {
        String Empty = '';
        Map<String, Map<String,List <SBQQ__Subscription__c>>> myMap = new Map<String, Map<String,List <SBQQ__Subscription__c>>>();
        List<SBQQ__Subscription__c> subscriptionResults_4 = 
        Database.query('SELECT Name, DeviceId__c, SBQQ__ProductName__c, SBQQ__SpecialPrice__c, SBQQ__NetPrice__c, Location__c, SBQQ__ProductOption__r.SBQQ__OptionalSKU__c, SBQQ__ProductOption__r.SBQQ__Selected__c, SBQQ__ProductOption__r.SBQQ__QuantityEditable__c, SBQQ__ProductOption__r.SBQQ__Quantity__c, SBQQ__ProductOption__r.SBQQ__MinQuantity__c, SBQQ__ProductOption__r.SBQQ__MaxQuantity__c, SBQQ__ProductOption__r.SBQQ__Number__c, SBQQ__ProductOption__r.ProductCategory__c,SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c FROM SBQQ__Subscription__c WHERE DeviceId__c = : DeviceId AND SBQQ__ContractNumber__c  =: ContractNumber AND Location__c = :Empty ORDER BY SBQQ__ProductOption__r.SBQQ__Number__c');
       
         for(SBQQ__Subscription__c sub: subscriptionResults_4){
			if(!myMap.containsKey(sub.SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c)){
               myMap.put(sub.SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c,new Map<String, List <SBQQ__Subscription__c>> {sub.SBQQ__ProductOption__r.ProductCategory__c => new List <SBQQ__Subscription__c>{sub}});
            }
			else {
                if(!myMap.get(sub.SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c).containsKey(sub.SBQQ__ProductOption__r.ProductCategory__c)){
                    myMap.get(sub.SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c).put(sub.SBQQ__ProductOption__r.ProductCategory__c,new List <SBQQ__Subscription__c>{sub});
				}
				else{
                    myMap.get(sub.SBQQ__ProductOption__r.SBQQ__Feature__r.SBQQ__Category__c).get(sub.SBQQ__ProductOption__r.ProductCategory__c).add(sub);
				}
            }
         }
         
        return myMap;
    }
}

I don't know if this is relevant still, but my VF page is called ActiveSubscriptions.vfp.

Thank you!
Violeta Grigorova 3Violeta Grigorova 3
Hi, Bhanu,

I craeted a new VisualForce page - an exact copy of the last one, but with a different name and the same controller code, but with a different name. So, now I want to create a new package (due to the last one not working properly with constantly changing names of classes following a naming convention). But I cannot see my new page in the Package Manager. I could see it in the list of VF pages in Setup and I have assigned all the neccessary user permissions to it. Why am I not able to see it in the list in the Package Manager, this is strange to me, as I am following the exact same procedure and order of doing things as before. Any ideas would be appreciated.

Thank you