+ Start a Discussion
Raj Pandey 29Raj Pandey 29 
trigger onlyoneaccountopportunitycreate on Opportunity (before insert) {

    Set<id> accId = new Set<id>(); // Always try to use set
    for(opportunity opp : trigger.new)
    {
        if(opp.AccountId != null)
        {
            accId.add(opp.AccountId);    
        }
        }
    

    Map<Id,Account> mapAccount = new Map<Id,Account> ( [select id,(select id from opportunities) from account where id IN : accId ]) ;
    for(opportunity opp:trigger.new)
    {    
        
        if( opp.AccountId != null && mapAccount.containsKey(opp.AccountId) )
        {
            Account acc = mapAccount.get(opp.AccountId);
            if(acc.opportunities.size() > 0 )
            {
                opp.addError('you can not add more then once opportunity for this account'); 
            }
        }
    }

}

Please see the above code & help me to write a trigger that allow only one opportunity associated with an account in a day.
Best Answer chosen by Raj Pandey 29
Abhishek BansalAbhishek Bansal
Please close this question by marking the answer as Best Answer so that it will be helpful to others 
Naren9Naren9 
Hi All,
In Salesforce Lightning, do we have any option to remove/disable the Drilldown/View report hyper link on Dashboard?.

Thanks,
Naren
Best Answer chosen by Naren9
NagendraNagendra (Salesforce Developers) 
Hi Naren,

Sorry for this issue you are facing.

Unfortunately, this is not possible as of now. There is an idea which is active on the success community for which you can upvote so that it can be available in the mere future.

You can find the idea at the below link. Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
TemesgennnTemesgennn 

Hi all,

Is it possible to display a spinner while a visualforce component is loading in our Org? We created a visualforce page and used it as a component to display a table for our users. I have tried some solutions but no success so far, my code and solution could be totally wrong i am new to this.

Thank you very much for your help, this is my code:
 

<apex:page standardController="Class__c" extensions="ClassAttendanceTableController" lightningStylesheets="true">

    <head>
        <apex:slds />
    </head>
    <apex:form>
        <style>
                .spinnerBg{
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    background-color: #000;
                    opacity: 0.2;
                    z-index: 999999;
                }
                .spinner{
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    background-image: url("/img/loading32.gif");
                    background-size: 16px;
                    background-repeat: no-repeat;
                    background-attachment: fixed;
                    background-position: center;
                    z-index: 9999999;
                    opacity: 1;
                }
   </style>
   
    <apex:actionStatus id="spinnerStatus">    
                    <apex:facet name="start">
                     <div class="spinnerBg" />
                    <div class="spinner" />
                </apex:facet>
    </apex:actionStatus>
   
     <apex:commandButton action="{!save}" value="Save" status="spinnerStatus" reRender="theForm"/>
        <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-scrollable" >
            <thead>
                <tr class="slds-line-height_reset">
                    <th scope="col">
                        <div class="slds-truncate" title="Student Name">Student</div>
                    </th>
                    <apex:repeat value="{!attendanceDates}" var="date">
                        <th scope="col">
                            <div class="slds-truncate">
                                <apex:outputText value="{0, date, MMMM d',' yyyy}">
                                    <apex:param value="{!date}" />
                                </apex:outputText>
                            </div>
                        </th>
                    </apex:repeat>
                </tr>
            </thead>
            
            <tbody>
                <apex:repeat value="{!attendanceNames}" var="name">
                    <tr>
                        <td data-label="Student Name" scope="row" class="slds-truncate">
                            <apex:outputText value="{!name}" />
                            <apex:repeat value="{!attendanceRecords}" var="records">
                                <apex:outputPanel rendered="{!name == records.Student__r.name}">
                                    <td data-label="Present">
                                        <apex:inputField value="{!records.Present__c}" id="present" />
                                    </td>
                                </apex:outputPanel>
                            </apex:repeat>
                        </td>
                    </tr>
                </apex:repeat>
                
            </tbody>
            
        </table>
    </apex:form>
    
</apex:page>
Best Answer chosen by Temesgennn
ANUTEJANUTEJ (Salesforce Developers) 
Hi Temesgenn,

>> https://salesforce.stackexchange.com/questions/191203/visualforce-with-slds-spinner-embedded-in-a-page-layout#:~:text=If%20you%20want%20to%20use,live%20in%20an%20apex%3AactionStatus.

>> https://salesforce.stackexchange.com/questions/65580/popup-spinner-style-apexactionstatus

I was able to find the above implementation that has the similar use case of showing a spinner on the visualforce page when the data is loading, can you try checking this once?

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Salesforce Developer 60Salesforce Developer 60 
Hello ,
         I create a webservice for consuming rest api from .net . I am facing issue in test class for this . It's gives error callout not allowed from test method. How to write test class for below controller.
 
public with sharing class WebserviceCall {

    public WebserviceCall(ApexPages.StandardController controller) {

    }

    public String message {get; set;}
    
    public PageReference getaccesstoken() { 
      string jsonstring ='userName=test@gmail.com&Password=123&grant_type=password';
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
       // req.setClientCertificateName('Client Certificate');
       
        req.setEndpoint('http://google.com');
        req.setMethod('POST');
       // req.setHeader('SOAPAction', 'Soap Action');
        //req.setHeader('Authorization','Auth Token');
      
       req.setBody(jsonstring);
 
           try {
            res = http.send(req);
            message = res.getBody();
    TokenInformation token = new TokenInformation();
    token =(TokenInformation)System.JSON.deserialize(message, TokenInformation.class);
  // JSONParser parser = JSON.createParser(res.getBody());
            System.debug(token.access_token);
                 //HttpServletResponse httpResponse = (HttpServletResponse)response;
              string s = token.access_token;
            string a1 = s.substring(0,255);
            string a2 = s.substring(255,510);
            string a3 =s.substring (510,s.length());
            //Here SessionData__c is custom setting used for store access_token
       SessionData__c objToken = new SessionData__c();
       objToken.Name ='token2';
       objToken.Id ='a0G28000000ENAI';
    objToken.Access_Token1__c =a1;objToken.Access_Token2__c =a2;
               objToken.Access_Token3__c =a3;

upsert objToken;
               
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
             message = res.toString() + res.getBody();
            System.debug(res.toString());
        }
        return null;
        
}       
    
    
    
    
}

Best Answer chosen by Salesforce Developer 60
Shrikant BagalShrikant Bagal
Please try following 

/* MockResponse class implementing the HttpCalloutMock interface */
-----------------------------------------------------------------------------------------------------------------------------------------------------
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
   // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('http://google.com', req.getEndpoint());
        System.assertEquals('POST', req.getMethod());
  
       // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"access_token":"8UT28QKGORMivFqne-6PMRLdTYk3AS0mcxdVwRJEwYsTjwZjqGopk1TRzGX7vHSZpFNFL3HOmX3RKZrQkBap3b16j-XVkwArdDbhusArOBGzYsD1cpA8B87N_RedJrd9btvq2i22cAjPvyJLSVMc297U0V9YZ9rJ3tM429G8mglnsUNUVJJi_nnTJAN6-H038B4Y1aQeRQZVdU72Nr942eYZ3fXv1HXfxwYUZgWyYO5juVaVnoq_ZJHcrFGXfNp5LVrNlnEibHhJ2RGeD-MYKhyVjfkTrATGQhYY--OVCOemUyWKTlwgwBFjgzfpQfOq79raEglOTgEF3Qx78RY2-nBNvgOTRMET4B2fT17Q8EN4UCQLxGZTGq1ACN5j2B3YKT7isjzwAgysloYGJsL4j4D8dCGKgWBO0rTXwx7MfkNsX5TjAYRNCip5vTSRXeSBqhjM_TtwbKCA0HexikSz-XryZT7pKGYhjfRCXtWudd7OUjFYoDRfKTiAhjNk5yJj","token_type":"bearer","expires_in":86400,"userName":"test@gmail.com",".issued":"Thu, 25 Jun 2015 12:56:23 GMT",".expires":"Fri, 26 Jun 2015 12:56:23 GMT"}');
        res.setStatusCode(200);
        return res;
    }
}



----------------------------------------------------------------------------------------------------------------------------------------------------------------
/* Test Class getting fake response  from the class MockHttpResponseGenerator that implements HttpCalloutMock */
@isTest
private class CalloutClassTest {
     @isTest static void testCallout() {
       // Set mock callout class
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());  
       // Call method to test.
        // This causes a fake response to be sent from the class that implements HttpCalloutMock.
        PageReference pageRef = new WebserviceCall().getaccesstoken();
    }
}



Please mark as best answer so it will help to other who will serve same problem.
​Thanks!


 
svidyansvidyan 

Hi,

 

I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?

 

thanks

Svidya

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

It looks you havent create custom Tabs while defining custom objects first you need to create custom Tab for new objects Creating Tab Setup -->App Set up---> Create---> Tabs Click on new Tab [drop down shows all untabed objects ] select your object, set Tab style , click Next select profiles Save Adding To App Setup -->App Set up---> Create---> Apps Click on edit, edit available tab section Save Done Thanks, Bala

Bob_zBob_z 
I am recevieing the following error below that just stated happening today July 12. I'm not sure what would cause this error all of a sudden. If anyone can help me where to look for the issue i would appreciate it. It apprears to be coming from an install pacakge that is not active anymore called. Big Machine  for qouting.

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger BMXB.BMX_OpptyHandler caused an unexpected exception, contact your administrator: BMXB.BMX_OpptyHandler: execution of BeforeUpdate caused by: System.QueryException: sObject type 'QConfig__Model__c' is not supported.: Class.QConfig.configOpptyTriggerHandler.copySyncedQuoteIdToModels: line 38, column 1". 
Best Answer chosen by Bob_z
Bob_zBob_z
This error was caused by a salesforce version release which was rolled back to fixe errors.
PARAG BHORPARAG BHOR 
Can someone tell me how long it would take to become a Salesforce developer. (Considering to get a job as soon as possible) , Iam studying admin since past 1 month 5-6 hrs every day , I only know basic concepts of programming such as (data types, loops). I just Quit my job to dive in Salesforce.
Best Answer chosen by PARAG BHOR
RituSharmaRituSharma
Start with APEX developer guide. It will help you to start with the basics.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm
YiQin HeYiQin He 
Hi, 

I created a lightning component as a quick action button. In the component, I have a cancel button that I want it closed when user clicks.
User-added image

But the problem is that I cannot find any document explain how to close the modal dialog. This is the ui code:
<aura:component controller="ContactController" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
    <style>
        .changeRecordTypeRow {
        margin-top: 1.5rem;
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        }
        
        .changeRecordTypeLeftColumn {
        float: left;
        text-align: right;
        padding-right: 1.5rem;
        width: 35%;
        font-size: .8125rem;
        color: rgb(84, 105, 141);
        }
        
        .changeRecordTypeRightColumn {
        float: right;
        text-align: left;
        width: 65%;
        }
        
        .modal-body
        {
        	height:auto !important;
        	padding:0;
        }
        
        .forceChatterLightningComponent .bodyWrapper{height:100%;width:100%;padding:0;box-sizing:border-box}
    </style>
    <div class="modal-header slds-modal__header">
        <h2 class="title slds-text-heading--medium" >Change Contact Type</h2>
    </div>
    <div class="scrollable slds-modal__content slds-p-around--medium">
        <div class="changeRecordTypeRow">
            <fieldset class="slds-form-element">
                <div class="changeRecordTypeLeftColumn">
                    <legend class="form-element__legend slds-form-element__label">Select a record type</legend>
                </div>
                <div class="changeRecordTypeRightColumn slds-form-element__control">

                    <span class="slds-radio">
                        <input type="radio" id="radio_PrimaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_PrimaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Primary Contact</span>
                        </label>
                    </span>
                    <span class="slds-radio">
                        <input type="radio" id="radio_SecondaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_SecondaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Secondary Contact</span>
                        </label>
                    </span>
                </div>
            </fieldset>
        </div>
	</div>
    <div class="modal-footer slds-modal__footer">
    	<div class="forceChangeRecordTypeFooter">
        	<button type="button" class="slds-button slds-button--neutral .slds-modal__close" aura:id="btnCancel" >
            	Cancel
            </button>
            <button type="button" class="slds-button slds-button--brand" aura:id="btnSave">
            	Save
            </button>
        </div>
    </div>
</aura:component>
Does anyone have similar experience? Thanks in advance.
Best Answer chosen by YiQin He
YiQin HeYiQin He
Hi Karthik,

Thanks for the reply. I've already found the solution.
Call this method $A.get("e.force:closeQuickAction").fire() will close the modal dialog.

Yiqin
Pooja UpadhyayaPooja Upadhyaya 
Hello All  ,

I am preparing for Salesforce 201 certification .Please help me in finding appropraite material for the certification .

Thanks
Pooja Upadhyaya
Best Answer chosen by Pooja Upadhyaya
Amit Chaudhary 8Amit Chaudhary 8
Hi Pooja,

Please check all below link. I hope that will help you
http://sfdcgurukul.blogspot.in/p/salesforce-certification-dumps.html
http://www.proprofs.com/quiz-school/story.php?title=sfdc-adm-201-practice-exam
http://www.tquila.com/blog/2014/12/01/how-pass-adm-201-salesforce-certification-your-5-step-guide
https://success.salesforce.com/answers?id=90630000000gnNZAAY
http://focusonforce.com/salesforce-adm-201-exam-questions/
https://ctom971yahoo.wordpress.com/2015/03/24/salesforce-adm-201-pdf-dumps/
I found these exams very helpful when I was studying for my ADM 201 exam. These are not officlally provided by Salesforce, but I found the questions to be similar in style to the actual exam.

http://bulkified.com/Certifications/?certificationId=1
http://forcecertified.com/certifications/certified-administrator/practice-exam/
http://www.proprofs.com/quiz-school/story.php?title=sfdc-adm-201-practice-exam
http://www.proprofs.com/quiz-school/story.php?title=sfdc-adm-201-practice-exam-2


Please let us know if above link will help u

 
Mayank_SareenMayank_Sareen 
Hi all , 
I am new to salesforce and aim to be a certified developer , can anyone please give me some suggestions and tips on how to prepare for salesforce platform developer 1 exam.
Thanks
Best Answer chosen by Mayank_Sareen
Shubham NandwanaShubham Nandwana
Hi Mayank,
To prepare for developer 1 exam you can:
1. Follow study guide http://certification.salesforce.com/SG_CertifiedPlatformDeveloperI.pdf, clear your basics and you will be able to clear the exam.
2. Start with trail mixes suggested for developer 1 exam (https://trailhead.salesforce.com/users/00550000006yDdKAAU/trailmixes/prepare-for-your-salesforce-platform-developer-i-credential).
3. Check http://sfdctrail.com/2016/01/15/salesforce-platform-developer-1-certification-tips/ for topic wise distribution and study links for different topics. 
4. You can also find no. of sample questions on google. Like on such link: http://mansoorsfdc.blogspot.com/2016/12/salesforce-certified-platform-developer.html
NOTE: The DEV401 exam has been revised so do not rely solely on some question bank.

Select it as best answer if it helps and reply if any other help is needed.

Shubham Nandwana.
AppPerfect Corp.
salesforce@appperfect.com
408-252-4100
http://www.appperfect.com/services/salesforce/
Salesforce Development & Operations Experts