• Hargobind_Singh
  • SMARTIE
  • 1930 Points
  • Member since 2010
  • Tech Architect


  • Chatter
    Feed
  • 62
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 2
    Questions
  • 509
    Replies
@isTest 

public class AccRelatedContTest
{    
      static testmethod void updateOpp() {
      
             Account testAccount = new Account();
        
        testAccount.Name='Test Account' ;        
        testAccount.OwnerID = '005d0000003Xjjh';
        testAccount.Website = 'hopethisworks.com';
        testAccount.recordtypeid = '012d0000000PBVJ';
        insert testAccount;
        
        Contact cont = new Contact();
        cont.FirstName='Test';
        cont.LastName='Test';
        cont.Accountid= testAccount.id;
        insert cont;
        
      Opportunity o = new Opportunity(
        Name='Test Opp',
        NextStep = 'Testing',
        Accountid= testAccount.id,
        StageName = 'Prospect',
        Probability=100,
        CloseDate = date.today(),
        RecordTypeid = '012d0000000PDkW');
        insert o;
        
        
    }
}
This is the test class code attempting to provide code coverage for an opportunity create and update trigger. When I run it without the opportunity part it passes fine, but when I include it gives a "Methods defined as TestMethod do not support Web service callouts" error, which is frustrating because I'm not making any Web service callouts (I think?!)

Any help is greatly appreciated. Thanks.

Hey, I'm fairly new to this and haven't been able to find an answer elsewhere, or I have missed it. What I'm trying to accomplish is checking to see if the string has at least 2 characters and if it does I use that string inside a URL to create a barcode. If it is less than 2 then it will return a blank image instead of the barcode.

It just doesn't seem to be working that way, when I try to use the variable within the URL it "cuts" the URL at that point where I put it in and returns the basic barcode from the site.

-----

<apex:pageBlock >
    <apex:pageBlockSection id="Items" columns="1" 
            showHeader="true" collapsible="false">  
      <apex:pageBlockTable value="{!myOrder.OrderItems}" headerClass="hidden"  cellPadding="4"  border="0" var="item" > 
                            
      <apex:column headerValue="Customer P/N" width="25%"><apex:image id="CusPN" value="{!IF(LEN(item.PriceBookEntry.Product2.ProductCode)>2, 'http://generator.barcodetools.com/barcode.png?gen=0&data={!item.PriceBookEntry.Product2.ProductCode}&bcolor=FFFFFF&fcolor=000000&tcolor=000000&fh=8&bred=&w2n=2.5&xdim=2&w=250&h=30&debug=1&btype=2&angle=0&quiet=0&balign=2&talign=2&guarg=1&text=1&tdown=1&stst=1&schk=0&cchk=1&ntxt=1&c128=0', '---')}"/>
                </apex:column>
                
                <apex:column headerValue="CCM P/N" width="25%"><apex:image id="CCMPN" value="http://generator.barcodetools.com/barcode.png?gen=0&data={!item.PriceBookEntry.Product2.ProductCode}&bcolor=FFFFFF&fcolor=000000&tcolor=000000&fh=8&bred=&w2n=2.5&xdim=2&w=250&h=30&debug=1&btype=2&angle=0&quiet=1&balign=2&talign=2&guarg=1&text=1&tdown=1&stst=1&schk=0&cchk=1&ntxt=1&c128=0}"/>
                </apex:column>

-----

So those are the two columns, only the one needs to be checked while the other one works fine. Again my knowledge is fairly limited within VisualForce and Apex, and as far as I can tell when I'm trying to use the variable within the IF statement using { } it is cause the URL to get shortened to "http://generator.barcodetools.com/barcode.png?gen=0&data=" which is exactly what I'm getting as an output.

Thanks for all the help!

Hi Experts,

I have requirement i have two fields called Street(acitvity__r.street__c) and Town(acitvity__r.Town__c) which are formula fields, so while displaying the record, if i didnt enter the value in the Town field, comma should not display in the record. could anyone tell me how to do that.
This is my visual force line 
<td class="value" colspan="6"><b>Works Location/Address:</b>&nbsp;{!Non_Compliance__c.Street__c}&nbsp;&nbsp;{!Non_Compliance__c.Town__c}</td>

When using the the salesforce GUI to define Custom Buttons and Formulas, is it possible to include comment lines within the code?
Is anyone else having this issue where the ORDER BY StageName actually reports back Z to A?  If I do ORDER BY StageName DESC then it sorts A to Z.  This is backward!  It seems consistant but when reading the code you would expect a different result than what actually is returned.
Hi All,

there's a way to set the Finish Location to a login flow?

I've seen that this is possible including the flow in a Visualforce page, but this is not possibile (as far as I know) with login flows.

Thanks in advance.
I have a command button called send on my Vf page and requirement is to send email to the logged in user who is clicking that particular button. Can some one guide me how this can be done through apex code on thtat button Please stuck on this from long time.
I have this small piece of code here:
public class CreateDataFiscCode {
    public Contact createData(){
        Contact contact = new Contact
            (
                FirstName = 'Paolo',
    			LastName = 'Polio',
        		Birthdate = date.parse('12/12/1912'),
        		Birthplace__c = 'Attimis',
        		Provincia__c = 'UD',
        		Sesso__c = 'M'
        	);
        insert contact;
        return contact;
    }
}

I do not understand why when I execute anonymously just the mothod <createData()> I get the above error: Method does not exist or incorrect signature
Hi,

I saw articles which mentions how to use rich text fields, however the rich text fields deosn't support html code. However somewhere I was that we can even enable rich text fields which supports html code as well.
Any suggestions of how to add this kind of advanced fields can be created on to the saelsforce pagelayouts?

Regards,
Vijosh
I'm using Salesforce for Android and have the login screen come up after the splash screen. But I have multiple activities for the login screen come up at once. My question is what causes the login screen to come up?
Hi All 

I am trying to write test class for the below class but i couldn't achive this. Anyone have idea about it please explain me .

public class JSON2Apex {

    public class Address_components {
        public String long_name;
        public String short_name;
        public List<String> types;
    }

    public class Northeast {
        public Double lat;
        public Double lng;
    }

    public List<Results> results;
    public String status;

    public class Bounds {
        public Northeast northeast;
        public Northeast southwest;
    }

    public class Geometry {
        public Bounds bounds;
        public Northeast location;
        public String location_type;
        public Bounds viewport;
    }

    public class Results {
        public List<Address_components> address_components;
        public String formatted_address;
        public Geometry geometry;
        public Boolean partial_match;
        public String place_id;
        public List<String> types;
    }
}
Hi, 

I have a task like, I need to show Bar chart of Last month Coverted and Unconverted Leads. Done this on developer account by Creating report and Dashboards.

Is there any ways we can do the same on SALESFORCE1 MOBILE APP?.... I dont see New Report or New Dashboard section in Mobile.  But I can see the Dashboard that has been Created in developer account.

Thanks,

So I'm trying to make a very basic workflow that updates leaders that are being converted (basically just updating one custom checkbox to true), but for the life of me, I cannot seem to get it to actually seem to fire. Basic logic here 

 

ISCHANGED(Status) && OR(ISPICKVAL(Status, 'Qualified to Opportunity'), ISPICKVAL(Status, 'Attached to Account'))&& Accepted__c=False && SQL__c=True
Note that we have rules that required the above two status before conversion (so all converted ops go into one or the other). I have instead also checked it with Converted=True and Is changed on Convert and True but despite it all, the field update never seems to fire. Thoughts? 
I am importing data from csv files using the dataloader into two separate objects. 
The first csv file is loaded into the account.  The data loaded includes a unique client ID field.
The second csv file loads data into a custom object and includes the same client ID field.

Is there a way to look up the accountID so that I can relate the custom object to the account that contains the unique client ID using a trigger?
 
https://login.salesforce.com/17181/logo180.png
Failed to load resource: the server responded with a status of 404 (Not Found)

When I load a VF page of a open case, in the Javascript console, the first line of the output has this error. The instructions at the url says to contact support to fix the issue because the resource no longer exists.
Hello everyone,

If a logged email was sent to three different email addresses (as an example), we'd like to have a trigger that associates that Task to all three Contacts in Salesforce. I know we can manually associate a Task to multiple Contacts, but is this possible to do in Apex automatically? And if so, how would I go about writing the Name field to hold multiple Contacts?

Thanks!
-Greg
something strange happend, i have created a custom object,its related tab and linked it with the a user's profile, the profile has access on that object and app ,even i set the tab to "Default On" ,i have checked thoroughly but still i am not able to see the tab and not even in the "customize tabs" page,when logged in with that user account. i wonder what migh have happend ?
Greetings, 

Our team is developing a QR code system, in which we have the ability to access certain salesforce records using the QR code provided. The QR Code has a url of the salesforce record intact. I am trying to figure out a way in which I can scan the code and it bypasses the login page to go directly to the record. I have no issues with accessing in Salesforce1. I surmise this might be a matter of Single Sign On.
Hello,

I need to create a new date field:

Date Field = Effective Date - Text(3) - 90
Text(3) default is "60" but may be changed to any number

Thanks in advance.

Hi,

 

Is there any way that a web-service call-out can be scheduled ? i don't want to use Cronkit, and by the documentation it seems like the batch Apex now supports it, but since scheduled apex doesn't support it, does that mean that we cannot schedule callouts for now ? 

 

Or am I wrong somewhere in the above paragraph ? 

 

Thx....

Hi,


I am trying to take out profile security settings using the Metadata API. But, some important security settings are missing from the profile xml..., like the standard object permissions. 

 

Where can I find those ?

 

 

This validation rule syntax is fine and saves.  But the opportunity record does not error when the Texture__c field is blank.

AND( 
$RecordType.Name = "REDSHOES", 
Probability > 30, 
OR( 
ISBLANK(TEXT( Texture__c )), 
ISBLANK(TEXT( Category__c )), 
ISBLANK( Amount ) 
))
@isTest 

public class AccRelatedContTest
{    
      static testmethod void updateOpp() {
      
             Account testAccount = new Account();
        
        testAccount.Name='Test Account' ;        
        testAccount.OwnerID = '005d0000003Xjjh';
        testAccount.Website = 'hopethisworks.com';
        testAccount.recordtypeid = '012d0000000PBVJ';
        insert testAccount;
        
        Contact cont = new Contact();
        cont.FirstName='Test';
        cont.LastName='Test';
        cont.Accountid= testAccount.id;
        insert cont;
        
      Opportunity o = new Opportunity(
        Name='Test Opp',
        NextStep = 'Testing',
        Accountid= testAccount.id,
        StageName = 'Prospect',
        Probability=100,
        CloseDate = date.today(),
        RecordTypeid = '012d0000000PDkW');
        insert o;
        
        
    }
}
This is the test class code attempting to provide code coverage for an opportunity create and update trigger. When I run it without the opportunity part it passes fine, but when I include it gives a "Methods defined as TestMethod do not support Web service callouts" error, which is frustrating because I'm not making any Web service callouts (I think?!)

Any help is greatly appreciated. Thanks.
How to attach a record in the encrypted field? It will be very helpful if you elaborate. Thanks in advance.
Hello

We read in the documentation ( https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_limits.htm ) that there is a limit of 2000 records for a query in the salesforce database. We need to query all contacts that are available to the connected user, is there a way to do a cursored query until it goes through all contacts? Or something else?
I wanted to get some thoughts and experiences from folks around their use of Jitterbit vs. SCRIBE.  Please let me know your thoughts.  We are working with SCRIBE today and looking to see what Jitterbit can do for us. We have a new ServiceMax project that wants to introduce Jitterbit and curious folks thoughts about it.  Thanks for your time.
I need to create a dependent look in visualforce page.When i am selecting data from main look up field need to fetch look up data from child look up field
Hello All

I am preparing for security review. I have created one Free App and want to send it for review. My app has third party access to API and Our Portal.

API URL :: devapi.xyz.com
Third Party Portal :: www.dev-abc.com


These are my development sites and open to access from anywhere without any VPN. Now when I will release my free app these url will change to following.

Production URL
API URL :: api.xyz.com
Third Party :: www.abc.com


Now my question is that, do I need to send package for review with development url or production url?
Last time I sent with Production url and Salesforce created test data and that affected our Production customer which created lots of problem.

I want to avoid this situcation this time while security review.

Help/Sugggestions required on this situation.

Thank you
I'm using the Nonprofit Starter Pack and I would like a way for volunteer hours to displace on household(account) pages as well as the contact page. I have already added an account lookup field, because I can't use Master-Detail. I think those have already been used for the contact and the volunteer job. So now I'm trying to create a trigger that updates the Total Hours field on the account, which is a sum of the hours field on the volunteer hour object. My question is how do I write code to sum those hours for the correct? Here's where I am thus far.
trigger RollupVolunteerHours on Volunteer_Hours__c (After insert, after update, after delete) {
	Set<Id> AccountIds = new Set<Id>();
    list<Volunteer_Hours__c> vHours = [SELECT Id, Hours__c FROM Volunteer_Hours__c WHERE Id IN :trigger.new];
    for(Volunteer_Hours__c vh :trigger.new){
        AccountIds.add(vh.Account__r.Id);
    }
	
    list<Account> acctList = [SELECT Id, Total_Hours__c FROM Account WHERE Id IN :AccountIDs];
    
    For(Account acct : acctList){
        //acct.Total_Hours__c = Summation of Volunteer_Hours__r.Hours__c
        
        update acct;
    }
}

Am I on the right track? How do I use what I have to do what I want? If something is unnecessary, why? Same for missing. I'm fairly new to apex so please explain steps instead of giving me code. I want to learn and understand!

Thanks!

Hi guys,

Does anyone know why a REST API call to salesforce end up to "503 Service unavailable"?

Following is the error message sent by salesforce to our application:
15:18:14,914 WARN [org.springframework.web.client.RestTemplate] (default task-11) GET request for "https://na30.salesforce.com/services/data/v23.0/chatter/users/me" resulted in 503 (Service Unavailable); invoking error handler
15:18:14,929 SEVERE [com.silanis.esl.web.exception.mappers.ThrowableMapper] (default task-11) No error details from Salesforce.: org.springframework.social.UncategorizedApiException: No error details from Salesforce.
at org.springframework.social.salesforce.api.impl.SalesforceErrorHandler.handleUncategorizedError(SalesforceErrorHandler.java:60) [spring-social-salesforce-1.1.7.1.jar:]
at org.springframework.social.salesforce.api.impl.SalesforceErrorHandler.handleError(SalesforceErrorHandler.java:28) [spring-social-salesforce-1.1.7.1.jar:]
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:566) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:524) [spring-web-3.2.13.RELEASE.jar:3.2.13.RELEASE]

Thanks,
Andry
I am having 6 fields on a VF page.All those fields are required and cant be left blank if name field is filled.

I am using <apex:pagemessages/ > in my Vf page and below is my code.
Problem which i am not able to solve is,when i give name value and left other fields blank,i am getting only one error message.
Like Phone is required.
When i enter phone and save it,i get billing street is required.

But i want to display all the error messages at once.(fields which are nit filled ..error messages related to those fields)

Please help.
Public pagereference save(){

    if(accountname!= '' && accountname!= null){
    
        account.name=accountname;
        if(phonenumber!= '' && phonenumber!=null)
        {
            account.phone=phonenumber;        
        }
        else{
        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Phone is required'));
        return null;
        }
        
        if(Billingstreet != '' && Billingstreet !=null)
        {
            account.billingstreet=Billingstreet;        
        }
        else{
        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Billing Street is required'));
        return null;
        }
        
        if(Billingcity != '' && Billingcity !=null)
        {
            account.billingcity=billingcity;
        }
        else{
        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Billing City is required'));
        return null;
        }
        
        if(billingzipcode != '' && billingzipcode !=null)
        {
            account.billingpostalcode=billingzipcode;
        }
        else{
        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Billing Zip is required'));
        return null;        
        }
        
        upsert account;
        
        contact c=new contact();
        c.accountid=account.id;
        
        if(contactname!= '' && contactname !=null){
            c.lastName=contactname;
        }else{

        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Contact Name is required'));
        return null;
        }
        if(contactemail!= '' && contactemail !=null){
            c.Email=contactemail;
        }else{
        ApexPages.addMessage(new apexpages.message(ApexPages.Severity.ERROR, 'Contact Email is required'));
         return null;
        }
       
        insert c;
        
    }
    
    return new PageReference('/'+pr.Id+'/e?retURL=%2F'+pr.Id);   
    }

 
Does anyone know where global picklist dependencies are stored?  Standard picklists you can see them in the XML but not for global picklists.
Hello,

I am having trouble wrapping my head around something.  We are setting up a Web-To-Case integration where a Case will be created when an internal system receives an alert.  The Case will have an internal identifier field that is also populated on the Case record.  All that is fine, however, if multiple alerts occur for Cases with the same internal identifier, I need to create the case via web-to-case, search for any open cases with that internal identifier, add a new custom object record linked to the existing case, and then delete the new case.  The end result would be 1 open case per identifier, with potentially multiple custom object records.  Can anyone suggest how I can do this with a trigger or some other method?
External system(SharePoint) is making SOAP API call to create a record in salesforce, on which creation of records upon meeting a field criteria a workflow should be triggered in updating field values. When a record is created through Salesforce UI the workflow runs fine but when it is getting created through API call seems like workflow is not running. 

So is it something like we cannot invoke Workflow/Aprroval process in sfdc through external API call? If so what thinigs should be done to trigger Workflow/approval process through external SOAP API calls?

Hi Guys,
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added few filter fileds like date range ,staus etc so that I can refine the case list based on my requirement.If I click on any case from the list it should redirect to case detail page and in case detail page I have a "back" command link which will take us to orginal "List of Cases"page on clicking.
Now the requirement is if I apply case filter data range as yesterday's date to today's date and it retuns 1 case, after clciking on that case it should redirect to the case detail page as mentioned before and after clicking the back command link in case detail page it should redirect back to refined serach result (it should show that 1 case in the list not all the cases) not to the original "List of Cases".please note thst url is not changing when applying the case filters in "List of Cases" page.
Thanks for your help in advance.
Hello, I want to make insurance app for one of my customer. There is an insurance salesforce edition (Professional edition) which is a sales app. When i searched on google on one of the websites it was given that it include 2 custom objects carrier and policies. But when i registered for 30 day trial for that edition it had only sales app there were no custom objects.
So should i need to make this custom object.
Or should customize sales app as per client requirement.
Please tell me how start project once license copy is accquired by customer.
String strObjProsPrefix = Schema.MCPM_Prospect__c.getSobjectType().getDescribe().getKeyPrefix();
        String strQuery = 'Select Id, MCPM_Email_Reminder_Interaction__c, MCPM_Prospect_Email_For_Reminder__c, '+
                                  'MCPM_Premise_Lookup__c, MCPM_Prospect__c'+  
                                  'from MCPM_Interaction__c where ';
        if(strRecordId.startsWith(strObjProsPrefix)){
            strQuery += 'MCPM_Prospect__c=  \''+String.escapeSingleQuotes(strRecordId)+'\' and '+
                         'MCPM_Email_Reminder_Interaction__c  = true ' +
                                                          'ORDER BY CreatedDate DESC LIMIT 1 ';
        }                                                 
        else{
            strQuery += 'MCPM_Premise_Lookup__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and ' +
                                 'MCPM_Email_Reminder_Interaction__c = true'+ 
                                                          'ORDER BY CreatedDate DESC LIMIT 1 ';
        }                                                
                                                          
        List<MCPM_Interaction__c> objInterction = Database.query(strQuery);


Hi I am getting above error, tried many thing don't know what's going wrong.
Please help,
 
Hey this is my first page in visual force the scenario is following :- 

1. Create a VF page which can take parameter id of an user,
if no parameter is passed then it should take current logged in used id.
 
2 .Show all the accounts related to above user in drop down list (Label Accounts), Once the user select an account from drop down list, then show another drop down list (Label Notes) which should contain list of all the notes (Title) associated to that Account
 
3. Once user select notes record, it should display record values.
 
4. There should be edit button and once user clicks on edit, user should be able to edit it and save the same (this should happen only for records which are not private)
 
5. Edit button should not be displayed for Notes which are Private.
 
6. Place validations on drop down and record edit using apex page messages to show appropriate error and confirm message on successful edit.


 
Is it possible to record an email alert in the Email Object - NOT AN ACTIVITY EMAIL, but in the Email section that allows responses to automatically log to a case?
Use Case:  Send an email using a template upon Case creation that records in the email section and not as a task or activity.  A user can see the email and reply to customer with case thread response functionality in place. 
Hi Guys, 
I would like to create a custom button with Content Source as URL. 
Is there a way we can can dynamic url i.e. with IF in the url? 
example
/a06/e?CF00N2700000behac={!Contact.Last_Name}&IF(Field='a value', RecordType=012O00000006Fiaa , RecordType=012O00000006Fibb)?

If not, can you please give me an example in Java Script

Thanks,
Hi,

We have a VisualForce (VF) page that renders as a pdf. I have an automated email that is going to be trigger when criteria A, b, and C are met. 

How can i attach the pdf from the VF page as an email attachment in the automated email that is sent from an apex trigger or class?
  • October 25, 2015
  • Like
  • 1
Dear all,

I was looking into the community some solutions about how to create complex SQL Scripts.

Last week, I started in a company that they use SalesForce. So I have been learning about it.

I would like to receive some advices about create complex tables join​ (Inner Join, Left join, etc). Salesforce doesn't offer this funcionalities as SQL Server.

Thanks in advance for your support. I hope to become an expert soon and help other people.