+ Start a Discussion
Visithra NaagarajanVisithra Naagarajan 
I have to check my contact number not to be blank once i entered my name field.
if name field is not entered then contact number is also not needed.
Best Answer chosen by Visithra Naagarajan
AnkaiahAnkaiah (Salesforce Developers) 
Hi Visithra,

Try with below rule.
AND(NOT(ISBLANK(Name)), ISBLANK(Phone))

If this helps, Please mark it as best answer.

Thanks!!​​​​​​​

 
Ratheven SivarajahRatheven Sivarajah 
Hey everyone I have a quick question I have a outputlink that looks like a button and I want it to hover when I go over it. This is my code. Thank you in advance.

<style type="text/css">
    [id*=button] {  background-color: white !important;
                    border: 1px solid black !important;
                    color: black !important;
                    text-decoration: none !important;
                    padding: 9px !important;
                    cursor: pointer !important;
 }
 [id*=button:hover] {  background-color: white !important;
                }
 [id*=wrapper] {  
                    margin: auto;
                    width: 50%;
                    text-align: center !important;
                    padding: 10px;
                    height: 100px !important;
                }
   
</style>
    <div id="wrapper">
     <apex:repeat value="{!TechnologyProduct}" var="res" >
            <apex:outputPanel rendered="{!res.Detail_Link__c != null}" layout='none'>
                    <apex:outputlink value="{!res.Detail_Link__c}" styleClass="btn" id="button"> {!res.Detailed_Product_Name__c} </apex:outputlink>                  
            </apex:outputPanel>
     </apex:repeat>
    </div>
</apex:page>
Best Answer chosen by Ratheven Sivarajah
Shri RajShri Raj
<style type="text/css">
    [id*=button] {  
                    background-color: white !important;
                    border: 1px solid black !important;
                    color: black !important;
                    text-decoration: none !important;
                    padding: 9px !important;
                    cursor: pointer !important;
 }
 [id*=button:hover] {  
                    background-color: lightgray !important;
                }
 [id*=wrapper] {    
                    margin: auto;
                    width: 50%;
                    text-align: center !important;
                    padding: 10px;
                    height: 100px !important;
                }
</style>
<div id="wrapper">
    <apex:repeat value="{!TechnologyProduct}" var="res">
        <apex:outputPanel rendered="{!res.Detail_Link__c != null}" layout='none'>
            <apex:outputLink value="{!res.Detail_Link__c}" styleClass="btn" id="button">{!res.Detailed_Product_Name__c}</apex:outputLink>
        </apex:outputPanel>
    </apex:repeat>
</div>

 
Sudeep SinghSudeep Singh 
I have written a batch which is creating order and order item when contract status activated.
When the order is created the status field is showing "Draft" which is giving default value as we cannot change anything while creating order.

So, I need to set that Status to "Order Placed" instead of "Draft".

Here is the Batch :- 

/* Class Type :- Batch
* Date :- 
* Description :- Creates a new order if Contract Status is Activated after one month and update Next Order Date
* Author :- 
*/ 
global class AutoSubscriptionForOrderCreation implements Database.Batchable<sObject>,schedulable {
    Public void execute(SchedulableContext sc) 
    { 
        database.executebatch(new AutoSubscriptionForOrderCreation());
    }
    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date orderCreationDate = system.today().addDays(3);
        //system.debug('output'+[SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,ShippingAddress,BillingAddress,Insurance__c From Contract Where Status = 'Activated' And Next_Order_Date__c = TODAY]);
        if(Test.isRunningTest()){
            return Database.getQueryLocator([SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,account.PersonContactId,ShippingAddress,BillingAddress,Insurance__c,BillingState,BillingCity,BillingStreet,BillingCountry,BillingPostalCode,BillingLatitude,BillingLongitude,ShippingStreet,ShippingState,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingLatitude,ShippingLongitude,CustomerSignedId From Contract]);
        }else{
           return Database.getQueryLocator([SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,account.PersonContactId,ShippingAddress,BillingAddress,Insurance__c,BillingState,BillingCity,BillingStreet,BillingCountry,BillingPostalCode,BillingLatitude,BillingLongitude,ShippingStreet,ShippingState,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingLatitude,ShippingLongitude,CustomerSignedId From Contract Where Status = 'Activated' And Next_Order_Date__c =: orderCreationDate]); 
        }
    }
    
    global void execute(Database.BatchableContext bc, List<Contract> contractlst) {
        List<Order> orderlsttoinsert = new List<Order>();
        List<OrderItem> orderItemsToInsert = new List<OrderItem>();
        List<Contract> contractupdatelst = new List<Contract>();
        map<Id, Id> contractProdMap = New map<Id, Id>();
        if(contractlst.size() > 0){
            
            Pricebook2 priceBook = [select id, name from Pricebook2 where isStandard = true limit 1];
            List<PriceBookEntry> priceBookEntryList = [SELECT Product2.Id, Product2.Name, UnitPrice FROM PriceBookEntry WHERE Pricebook2Id =:priceBook.id];            
            //Set <Id> accid  = new set <Id>();
            //List
            for(Contract con: contractlst){
                //Insert Orders
                Order orderObj = new Order();
                orderObj.AccountId = con.AccountId;
                orderObj.Status = 'Draft';
                orderObj.ContractId = con.Id;
                orderObj.EffectiveDate = System.today();
                orderObj.Pricebook2Id =  priceBook.id;
                orderObj.Insurance__c =  con.Insurance__c;
                orderObj.Type = 'Subscription Order';
                orderObj.BillingStreet = con.BillingStreet;
                orderObj.BillingState = con.BillingState;
                orderObj.BillingCity = con.BillingCity;
                orderObj.BillingCountry = con.BillingCountry;
                orderObj.BillingPostalCode = con.BillingPostalCode;
                orderObj.BillingLatitude = con.BillingLatitude;
                orderObj.BillingLongitude = con.BillingLongitude;
                orderObj.ShippingStreet = con.ShippingStreet;
                orderObj.ShippingState = con.ShippingState;
                orderObj.ShippingCity = con.ShippingCity;
                orderObj.ShippingCountry = con.ShippingCountry;
                orderObj.ShippingPostalCode = con.ShippingPostalCode;
                orderObj.ShippingLatitude = con.ShippingLatitude;
                orderObj.ShippingLongitude = con.ShippingLongitude;
                orderObj.ShipToContactId =con.account.PersonContactId; 
                orderObj.BillToContactId = con.account.PersonContactId;
                orderObj.EffectiveDate = con.Next_Order_Date__c;
                orderlsttoinsert.add(orderObj);
                
                //Create Contract and Product Map
                for(PriceBookEntry pBookEntry : priceBookEntryList){
                    if(pBookEntry.Product2.Id == con.Service__r.Id){
                        contractProdMap.put(con.Id, pBookEntry.Id);
                    }
                }
                
                // Update order date to next month's nearest Wednesday
                Date nextOrderDate = ((System.today().addMonths(1)).toStartOfWeek().addDays(3));
                con.Next_Order_Date__c = nextOrderDate;
                contractupdatelst.add(con);
                
            }
            if(orderlsttoinsert.size() > 0){
                insert orderlsttoinsert;               
                for(Order O: orderlsttoinsert){
                    //Insert Order Items
                    OrderItem oi = new OrderItem();
                    oi.OrderId = O.id;
                    oi.Quantity = 1;
                    oi.UnitPrice = 1;
                    oi.Product2id = O.Contract.Service__c;
                    oi.PricebookEntryId = contractProdMap.get(O.ContractId);
                    oi.sstation__Currency_Type__c = 'USD';
                    orderItemsToInsert.add(oi);
                }    
            }
            if(orderItemsToInsert.size() > 0){
                insert orderItemsToInsert;
            }
            if(contractupdatelst.size() > 0){
                update contractupdatelst;
            }
        }
    }    
    global void finish(Database.BatchableContext bc) {
        
    }
}
Best Answer chosen by Sudeep Singh
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sudeep,

Can you try code as below.
 
/* Class Type :- Batch
* Date :- 
* Description :- Creates a new order if Contract Status is Activated after one month and update Next Order Date
* Author :- 
*/ 
global class AutoSubscriptionForOrderCreation implements Database.Batchable<sObject>,schedulable {
    Public void execute(SchedulableContext sc) 
    { 
        database.executebatch(new AutoSubscriptionForOrderCreation());
    }
    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date orderCreationDate = system.today().addDays(3);
        //system.debug('output'+[SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,ShippingAddress,BillingAddress,Insurance__c From Contract Where Status = 'Activated' And Next_Order_Date__c = TODAY]);
        if(Test.isRunningTest()){
            return Database.getQueryLocator([SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,account.PersonContactId,ShippingAddress,BillingAddress,Insurance__c,BillingState,BillingCity,BillingStreet,BillingCountry,BillingPostalCode,BillingLatitude,BillingLongitude,ShippingStreet,ShippingState,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingLatitude,ShippingLongitude,CustomerSignedId From Contract]);
        }else{
           return Database.getQueryLocator([SELECT Id,Status,Next_Order_Date__c,Service__r.id,AccountId,account.PersonContactId,ShippingAddress,BillingAddress,Insurance__c,BillingState,BillingCity,BillingStreet,BillingCountry,BillingPostalCode,BillingLatitude,BillingLongitude,ShippingStreet,ShippingState,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingLatitude,ShippingLongitude,CustomerSignedId From Contract Where Status = 'Activated' And Next_Order_Date__c =: orderCreationDate]); 
        }
    }
    
    global void execute(Database.BatchableContext bc, List<Contract> contractlst) {
        List<Order> orderlsttoinsert = new List<Order>();
        List<OrderItem> orderItemsToInsert = new List<OrderItem>();
        List<Contract> contractupdatelst = new List<Contract>();
        List<Order> ordertoupdate= new List<Order>();
        map<Id, Id> contractProdMap = New map<Id, Id>();
        if(contractlst.size() > 0){
            
            Pricebook2 priceBook = [select id, name from Pricebook2 where isStandard = true limit 1];
            List<PriceBookEntry> priceBookEntryList = [SELECT Product2.Id, Product2.Name, UnitPrice FROM PriceBookEntry WHERE Pricebook2Id =:priceBook.id];            
            //Set <Id> accid  = new set <Id>();
            //List
            for(Contract con: contractlst){
                //Insert Orders
                Order orderObj = new Order();
                orderObj.AccountId = con.AccountId;
                orderObj.Status = 'Draft';
                orderObj.ContractId = con.Id;
                orderObj.EffectiveDate = System.today();
                orderObj.Pricebook2Id =  priceBook.id;
                orderObj.Insurance__c =  con.Insurance__c;
                orderObj.Type = 'Subscription Order';
                orderObj.BillingStreet = con.BillingStreet;
                orderObj.BillingState = con.BillingState;
                orderObj.BillingCity = con.BillingCity;
                orderObj.BillingCountry = con.BillingCountry;
                orderObj.BillingPostalCode = con.BillingPostalCode;
                orderObj.BillingLatitude = con.BillingLatitude;
                orderObj.BillingLongitude = con.BillingLongitude;
                orderObj.ShippingStreet = con.ShippingStreet;
                orderObj.ShippingState = con.ShippingState;
                orderObj.ShippingCity = con.ShippingCity;
                orderObj.ShippingCountry = con.ShippingCountry;
                orderObj.ShippingPostalCode = con.ShippingPostalCode;
                orderObj.ShippingLatitude = con.ShippingLatitude;
                orderObj.ShippingLongitude = con.ShippingLongitude;
                orderObj.ShipToContactId =con.account.PersonContactId; 
                orderObj.BillToContactId = con.account.PersonContactId;
                orderObj.EffectiveDate = con.Next_Order_Date__c;
                orderlsttoinsert.add(orderObj);
                
                //Create Contract and Product Map
                for(PriceBookEntry pBookEntry : priceBookEntryList){
                    if(pBookEntry.Product2.Id == con.Service__r.Id){
                        contractProdMap.put(con.Id, pBookEntry.Id);
                    }
                }
                
                // Update order date to next month's nearest Wednesday
                Date nextOrderDate = ((System.today().addMonths(1)).toStartOfWeek().addDays(3));
                con.Next_Order_Date__c = nextOrderDate;
                contractupdatelst.add(con);
                
            }
            if(orderlsttoinsert.size() > 0){
                insert orderlsttoinsert;  
                           
                for(Order O: orderlsttoinsert){
                    //Insert Order Items
                    OrderItem oi = new OrderItem();
                    oi.OrderId = O.id;
                    oi.Quantity = 1;
                    oi.UnitPrice = 1;
                    oi.Product2id = O.Contract.Service__c;
                    oi.PricebookEntryId = contractProdMap.get(O.ContractId);
                    oi.sstation__Currency_Type__c = 'USD';
                    orderItemsToInsert.add(oi);
                }    
            }
            if(orderItemsToInsert.size() > 0){
                insert orderItemsToInsert;
            }
            if(contractupdatelst.size() > 0){
                update contractupdatelst;
            }
            if(orderlsttoinsert.size() > 0){
            for(Order Or: orderlsttoinsert){
                Or.Status='Order Placed';
                ordertoupdate.add(Or);
            } 
            update ordertoupdate; 
        }   
        }
    }    
    global void finish(Database.BatchableContext bc) {
        
    }
}

Thanks,
 
Nikhil Tripathi 13Nikhil Tripathi 13 
Can we do a dummy update on past records using Flow? Any help will be appreciated
Best Answer chosen by Nikhil Tripathi 13
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Nikhil,

Yes if you update the records with dataloder and record satisfies the flow start condition and flow is active they will trigger the records.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
salesforce sfdxsalesforce sfdx 
Hi just a small sample code .
 
public class TargetPlanController {    
        
    @AuraEnabled    
    public static List <TargetPlan__c > fetchAccts(Id recordId) {    
            
        return [SELECT Name,Account__c,No_of_Leads__c,AccountCity__c,FROM TargetPlan__c where BP_Id__c =: recordId ];
          }      
        
}

How to write the Test Class for the Above code.. please let me know.
Thanks 
Prathusha Reddy.
 
Best Answer chosen by salesforce sfdx
Shri RajShri Raj
@isTest
private class TargetPlanControllerTest {
    static testMethod void testFetchAccts() {
        // Create test data
        Account testAccount = new Account(Name='Test Account');
        insert testAccount;
        TargetPlan__c testTargetPlan = new TargetPlan__c(
            Name='Test Target Plan',
            Account__c=testAccount.Id,
            No_of_Leads__c=10,
            AccountCity__c='Test City',
            BP_Id__c='12345'
        );
        insert testTargetPlan;

        // Call the method to be tested
        Id recordId = '12345';
        List<TargetPlan__c> result = TargetPlanController.fetchAccts(recordId);

        // Verify the results
        System.assertEquals(1, result.size(), 'Expected one Target Plan record');
        System.assertEquals(testTargetPlan.Name, result[0].Name, 'Expected Target Plan Name to match');
        System.assertEquals(testTargetPlan.Account__c, result[0].Account__c, 'Expected Account Id to match');
        System.assertEquals(testTargetPlan.No_of_Leads__c, result[0].No_of_Leads__c, 'Expected No of Leads to match');
        System.assertEquals(testTargetPlan.AccountCity__c, result[0].AccountCity__c, 'Expected Account City to match');
    }
}

 
Orbit LoveOrbit Love 
Hi everyone,

We have built an API integration that works great with the standard login.salesforce.com oauth flow but we want to add support for Sandboxes with API access at test.salesforce.com.

It does not appear that we have the ability to create a sandbox using our Developer Edition so we can't test our oauth flow with test.salesforce.com.

Is there a way to get a sandbox for testing purposes?
Best Answer chosen by Orbit Love
SubratSubrat (Salesforce Developers) 
Hello Orbit ,

Sandboxes are'nt  available in developer editions ...You should have licensed instanse to create sandboxes.. you can create sandboxes in Enterprise, Performance, Unlimited, and Database.com Editions only.

Have a look on below links 
http://www.salesforce.com/crm/editions-pricing.jsp

http://www2.sfdcstatic.com/assets/pdf/datasheets/DS_SalesCloud_EdCompare.pdf

Do not forget to select best answer to make our efforts visible in the developer forum.

Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help.

Thank you.
Ratheven SivarajahRatheven Sivarajah 
Hey So I have created a button where I want the !res.Detail_Link__c to be displayed in the button and I want it to go to the link when click on !res.Detail_Link__c and if there is no link the button should not be visible.

<apex:page controller="TechnologyProduct" lightningStylesheets="true">
    <apex:form>
    <apex:pageBlock>
    <apex:pageBlockSection title="Vitality Check Attributes">
            <apex:repeat value="{!TechnologyProduct}" var="res">
<apex:outputText value="{!res.Detail_Link__c}" /><br/>
       <apex:commandButton  value="{res.Detailed_Product_Name__c}"/>
            </apex:repeat>
    </apex:pageBlockSection>
         </apex:pageBlock>
        </apex:form>
</apex:page>
Best Answer chosen by Ratheven Sivarajah
Shri RajShri Raj
You can modify the apex:commandButton as follows:
<apex:commandButton value="{!res.Detailed_Product_Name__c}" onclick="window.location.href='{!res.Detail_Link__c}'" rendered="{!res.Detail_Link__c != null}" />
Ratheven SivarajahRatheven Sivarajah 
Hey I was able to do a SOQL and store it in a list. How do I return it and use it in my VF page. Thank you in advance

Controller:
public with sharing class TechnologyProduct {

    public TechnologyProduct() {
     List <Technology_Product__c> result = [SELECT Id, Name FROM Technology_Product__c where Account__c='00105000002oNIyAAM']; 
    }   
}
Best Answer chosen by Ratheven Sivarajah
Shri RajShri Raj
To return the list from the controller, you can add a getter method to return the list. In the Visualforce page, you can reference the getter method to display the data
 
public with sharing class TechnologyProduct {
    public List < Technology_Product__c> result {get; set;} 
    public TechnologyProduct() {
        result = [SELECT Id, Name FROM Technology_Product__c where Account__c='00105000002oNIyAAM']; 
    }   
}
 
<apex:page controller="TechnologyProduct">
    <apex:repeat value="{!result}" var="product">
        <p>{!product.Name}</p>
    </apex:repeat>
</apex:page>

 
Ratheven SivarajahRatheven Sivarajah 
I want to display some data from my custom object(Technology_product__c) using the id from the master-detail object(Account). Thank you in advance.

SELECT Name,(SELECT name FROM Technology_Product__r ) FROM Account WHERE Id='00105000002oNIyAAM'
Best Answer chosen by Ratheven Sivarajah
SubratSubrat (Salesforce Developers) 
Hello Ratheven ,

Requesting you to follow this article for reference -> https://www.sfdckid.com/2019/05/salesforce-soql-relationship-queries.html

Let me know if you still face any challenges .

Hope it helps !
Thank you.
Ratheven SivarajahRatheven Sivarajah 
Hey I am new to visualforce. I am coding through VScode. I am able to get the particular data and show it on my sandbox and It looks fine when I put lightningStyleSheet="true". When I put the page in a site the css changes. Is this because there is a wrapper over my page that is influencing the css. If so how would I find out? Is there a way to overpower that css? How do you write css in a apex page, do you create a different style page and connect? A lot of question I know, Thanks for the help. 

This is the code:
<apex:page controller="TestQuote"  lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false"  >
<apex:form  >
<apex:pageBlock >
<apex:pageBlockSection >
    <apex:pageBlockSectionItem >
    <apex:outputLabel value="Quote Request Name:" for="name" ></apex:outputLabel>
    <apex:outputField value="{!result.Quote_Request__r.name}" />
    </apex:pageBlockSectionItem>  
</apex:pageBlockSection>    
</apex:pageBlock>
</apex:form>
</apex:page>
  
Best Answer chosen by Ratheven Sivarajah
Shri RajShri Raj
To write CSS for a Visualforce page, you have several options:
Inline CSS: You can use the style attribute within HTML tags to apply CSS styles directly. For example:
<apex:outputLabel value="Quote Request Name:" for="name" style="font-size: 14px; color: #333;"></apex:outputLabel>
External CSS file: You can create a separate .css file and link it to your Visualforce page using the <apex:stylesheet> tag. For example:
<apex:stylesheet value="{!URLFOR($Resource.MyCSS, 'MyCSS.css')}" />
Apex CSS classes: You can define CSS styles in your Apex class using the <style> tag. For example:
<style type="text/css"> .quote-request-label { font-size: 14px; color: #333; } </style>
And then apply the class to your label using the styleClass attribute:
<apex:outputLabel value="Quote Request Name:" for="name" styleClass="quote-request-label"></apex:outputLabel>
To determine if the site wrapper is influencing the CSS, you can inspect the elements using the browser's developer tools to see what styles are being applied to your elements and from where. To overpower the site wrapper's CSS, you can add higher specificity to your own styles, or use !important to force your styles to take priority.

Below is an example for your code
<apex:page controller="TestQuote" lightningStylesheets="true" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false" >
apex:form
apex:style
/* Define your CSS styles here */
.custom-label {
font-weight: bold;
}
.custom-field {
margin-left: 10px;
}
</apex:style>
apex:pageBlock
apex:pageBlockSection
apex:pageBlockSectionItem
<apex:outputLabel value="Quote Request Name:" for="name" styleClass="custom-label"/>
<apex:outputField value="{!result.Quote_Request__r.name}" styleClass="custom-field"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>