• Swaraj Behera 7
  • 99 Points
  • Member since 2015
  • Salesforce Developer
  • Accenture

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 3
  • 65
How pro-grammatically can I verify the permissions on an object and its fields? I also need to find -programmatically- objects with no permission set through profiles or permission sets?
While converting lead to opportunity,i want to attach all the attachments from lead to opportunity.
I have written a trigger for this but its nor firing.Can you please help me on this.
trigger LeadConvert on Lead (after update) {

List<Attachment> lstattach=new List<Attachment>();

if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {

	System.debug('oppid' + Trigger.new[0].ConvertedOpportunityId);
	Attachment aa=[Select Id,ParentId from Attachment where ParentId=:Trigger.new[0].ConvertedaccountId];
	System.debug('attachment in lead' + aa );

if (Trigger.new[0].ConvertedOpportunityId != null) {

for(Attachment a:[Select Id,ParentId from Attachment where ParentId=:Trigger.new[0].ConvertedaccountId]){

  System.debug('parentid' +a.ParentId);


update lstattach;



In my current requirement i want to get all the attachments from lead and need to attach it in the opporunity after conversion.I have created a trigger in opportuniy but it did not work.Can anyone help me on this.

Thanks in Advance.
How to add override edit page under button links to the change set

how to used the custome setting with the workflow please give me a stypes

  • February 20, 2017
  • Like
  • 0
Greetings, I've created my external object for the Data Integration Specalist Superbadge and have configured my external ID as seen below, however, the challenge seems to not pass, indicating that the indirect lookup was not properly created. Here's how I set up the projectRef__c field, which was what I used to push data from the external object into the project object in Salesforce. Are there any steps, I need to take. Hope it helps.
User-added image

User-added image
what are visualforce components? why do we use them.

Hi All,

I have created a Visual force page for site user . so whenever i insert record on site ,it will give a error message and record is not inserted  .However when i click on preview visualforce and insert the data the record gets inserted. Can Anyone tell me the problem??
Hi, I need to write a test class for my httppost method which uses json as input. i have tried implementing a test class using the HttpCalloutMock Interface but the apex class gets 0% code coverage in that case. Please suggest how can i go about this.

My apex class:
global class MyClass{

    global static void updateMethod(){    
        try {        
            //get the json from the request
            RestRequest req1=RestContext.request;           
            String jsonInput= req1.requestBody.toString();       

            //create map for the obtained json input
            Map<String, Object> jsonMap = (Map<String, Object>) JSON.deserializeUntyped(jsonInput); 
            Id opptyId = String.valueOf(jsonMap.get('opportunity_SF_Id')) ;            
            //get the opportunity object       
            Sobject oppty = [SELECT id, description FROM opportunity WHERE id=:opptyId];
            //some more processing
            update oppty;        
        }catch(Exception e){
               System.debug('The following exception has occurred: ' + e.getMessage());
as i wrote in the title i've got this issue. the two classes i use are those:
public class ContainsProvaTest {
    static testMethod void prova(){
        ContainsProva prova1 = new ContainsProva();

public with sharing class ContainsProva {
    public void contains() {
        String name = 'Rossella';
        boolean result = name.contains('Ros');
        System.debug('Result is' + result);

Both classes are inside an Apex sandbox project.


test configuration

What's wrong with that?

I read that it could be a bug of salesforce. Can anyone helps me?


public with sharing class LP_CreateNewCasePage_Controller 

public String Id;
public Id ParentId;
public id selectedrecordtype;
 public PageReference OtherRedirect(){
           System.debug('Selected RecordType is'+selectedrecordtype);
           Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
           PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
           Map<String, String> m = p.getParameters();
                ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
                m.put('nooverride', '1');
                m.put('nooverride', '1');
                return p;

                m.put('nooverride', '1');
                return p;

   catch(Exception l_objEx)
            String l_stMsg = 'Exception while redirecting to Case Creation Page.';
            String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
            return null;

Thanks in Advance!
hello all

Below is my apex class could you please help me out to correct my test class to improve my code coverage 

public class callmeetings
    public Map<Id, Call_Meeting__c> cmMap {get; set;}
    public String selectedcm{get; set;}
    public String tuId;
    public callmeetings()
        tuId = ApexPages.currentPage().getParameters().get('tId');        
        cmMap = new Map<Id, Call_Meeting__c>([Select Id, Name, User__c, User__r.Name, Treating_Unit__c from Call_Meeting__c WHERE Treating_Unit__c = null]);
    public PageReference selectThis() {
            Call_Meeting__c tempMeeting = cmMap.get(selectedcm);
            tempMeeting.Treating_Unit__c = tuId;
            update tempMeeting;
            return (new PageReference('/'+tuId));
            return null;

Test class 

private class callmeetingsTest
    static testMethod void updateCallmeeting()
        id uopAccountId;
        Schema.DescribeSObjectResult d1 = Schema.SObjectType.Account;
        Map<String,Schema.RecordTypeInfo> rtMap1 = d1.getRecordTypeInfosByName();
        Schema.RecordTypeInfo uoprt =rtMap1.get('UOP Accounts');
        ContactRecordType__c rectype = new ContactRecordType__c();
        insert rectype;
        Profile p=[select id from Profile where Name='UOP - Business'];
        UOP_Profiles__c up=new UOP_Profiles__c();
        up.Name='UOP Profile ID List';
        insert up;
        sales_district__c sd=new sales_district__c();
        insert sd;
        system.debug('*******sales district********'+sd);
        Uop_geo_region__c ur=new Uop_geo_region__c ();
        ur.Name='INDIAN SUBCONTINENT';
        insert ur;
        SAP_Customer_Info__c testcustomer = new SAP_Customer_Info__c();       
        testcustomer.UOP_Company_Name__c='AGIPPETROIL SPA';
        testcustomer.UOP_Address1__c='DEVKARAN MANSION IIND FLR';
        testcustomer.UOP_Address2__c='79 PRINCESS STREET';
        insert testcustomer; 
        Country__c c=new Country__c();
        insert c;
        Account acc=new Account();
        acc.Name='Test Name';
        acc.BillingStreet ='sfdc';
        acc.BillingState ='sfdc';
        acc.BillingCountry ='INDIA';
        insert acc;

        acc= [Select OwnerID, Owner.ID From Account where ID = :acc.id];
        Treating_Units__c TU = New Treating_Units__c ();
        TU.Carrier_Stream__c='Natural GAS';
        insert TU;
        Call_Meeting__c CM = New Call_Meeting__c ();
        CM.Company__c= acc.ID;
        CM.Due_Date__c = Datetime.newInstance(2016, 8, 16);
        insert CM; 
How to display number of contact records associated with account in account page ?
I am trying to be a Recall Button on the Quote Page:  I am receiving the error: A problem with the OnClick JavaScript for this button or link was encountered:  Unexpected Identifier.

Apex Class:
global class approvalRecall
    webservice static void recallApproval(Id recId)    
        List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();


var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 

alert("Approval has been recalled"); 


alert("Recall Cancelled"); 
if I have 5 test methods and a test setup method in a test class and when we perform a test run on this class, in what sequence will the test methods execute during the testing?.
Hi Team,

Whenever update the Opty fields create a new brand task along with opportunity name. for that we have written a trigger working as expected. But once create a task if we update the description field it should creat a new task not overriding the exting task. 

Every time Step(OptyField) or Description(OptyField) changes, New task should be created

Example: Step = Legal,Description = test 

If I again select Step = Legal and Description = test1234  new task should be created. Currently its updating test to test1234.

Please Find my below trigger and let us know where we made the mistakes.

Trigger Task on Opportunity(after insert,after update){
Set<Id> opIds = new Set<Id>();
List<Task> taskList = new List<Task>();
List<Opportunity> Opps = Trigger.new;
List<Opportunity> taskOps = [Select Id,Steps__c,Description__c from Opportunity where Id in :opIds];
   for (Opportunity Opp: Opps){
        Task t = new Task();
        t.WhatId = opp.Id;
        t.Subject = 'Help' + ': ' +opp.Steps__c + ': '  + opp.Name; 
        t.Description = opp.Description__c;  
         t.ActivityDate = System.Today()+7;     
    Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
     for (Opportunity Opp: Opps){
         // description got changed
         if(Opp.Steps__c != oldOppMap.get(opp.Id).Steps__c ){
            Task t = new Task();
            t.WhatId = opp.Id;       
             t.Subject = 'Help' + ': ' +opp.Steps__c + ': '  + opp.Name; 
             t.Description = opp.Description__c;  
             t.ActivityDate = System.Today()+7;
insert taskList;

Thanks in Advance
Hi friends,I am getting an error for a trigger. Condition is: I want to create an product whenever I am creating any opportunity. In opportunity, product is on the based of dependent picklist. Error is -  Error    Error: Compile Error: Entity is not api accessible at line 1 column 1

Code is as below:

trigger CreateProduct on Opportunity (after insert) {
for(Opportunity opp: trigger.new){
Product pod = new Product();
pod.Name = opp.Select_Product__c;

pod.Opportunityid = opp.id;
insert pod;
  • August 12, 2016
  • Like
  • 0
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        SendmailUtils.Emailtemplate emailtmp=new SendmailUtils.EmailTemplate();
        if(Contactlists.size() == 0)
            ReturnContactList([SELECT Name,FirstName,LastName,description,Email,Title,Company,ID,phone FROM Lead where email=:Emailcon LIMIT 1]);
        string isQue='0';
        try {
            res = http.send(req);
            if (res.getBody() != null) {
                    List<SendmailUtils.EmailTemplateListData> emailLists=new List<SendmailUtils.EmailTemplateListData>();
                    String userName = UserInfo.getUserName();
                    User activeUser = [Select Email From User where Username = : userName limit 1];
                    String userEmail = activeUser.Email;
                    for(SendmailUtils.EmailTemplateListData emailData: emailLists)
                        if(emailData.To != null || emailData.To != '')
                            Messaging.SingleEmailMessage emails = new Messaging.SingleEmailMessage(); 
                            List<String> sendTo = new List<String>();
                            // System.debug ( 'emailData.To' +emailData.To);
                            emailData.Body = emailData.Body.unescapeHtml4();

        -----------:  Error shows in this below line:------         
     Messaging.SendEmailResult [] resSentEmail= Messaging.SendEmail(new Messaging.SingleEmailMessage[] {emails});  

                            for ( Messaging.sendEmailResult result : resSentEmail ) {
                                if ( !resSentEmail[0].isSuccess () ) {
                                  //  System.debug ( 'result' +result  );


Salesforce standard 'account' object has lookup relationship with standard 'contacts' object. i see a button 'new contacts' for adding contacts to the account record. I have a custom picklist field in standard object named 'status', (values: 'active', 'inactive' and 'to be remediated'),i want to ensure no contacts can be added to the account if the account 'status' picklist value is 'inactive'.

How do i do that? i am new to salesforce and appreciate your time in helping me, Thanks in advance.
here i was attached two pics 
my quetion is how to write a trigger as 
when creating a record in account, Account Name will comes to related contact last name
User-added image

User-added image

please help me,

Hi , 

I have small issue with the action function,i wrote acode in sucha way that i wnat to use the action function in my VF code . But wen i  run the VF code iam not seeing the data{'hiiiiiiiiiiiiiiiiiii) which i mentiond in the M1 method  in the debug logs\. So  i think my method m1 is not beoing called form the Java script and even aim not getting the alert also which i defined in the page. My code is ,

<apex:page controller="bang1">

<script type="text/javascript">
  function f1()
  alert ('Start invoking vf action!');
  <apex:form >
  <apex:actionFunction name="f1"   action="{!m1}"  />
  <apex:commandButton value="enter"  onclick="f1"     />


Public class bang1

Public void m1()




Pleasesuggest me.


public void saveAndSubmit()
        List<CaseComment> lstCmt = new List<CaseComment>();
        CaseComment cmt = new CaseComment();
        List<Technician_Appointment_Scheduler__c> lstTAS = new List<Technician_Appointment_Scheduler__c>();
        Boolean success = false;
        String strOli='';
            if(lstSelectedProviProduct!=null && lstSelectedProviProduct.size()>0)
                for(SelectionWrapper wrapper : lstSelectedProviProduct)
                    strOli += getSemiColonValid(wrapper.RecordId);

            if(SelectedMultiSite == false){
                troubleTicket.Service_Zip_Code__c = this.selectedAccount.Service_Location_Postal_Code__c;
                system.debug('===>>>Service_Zip_Code__c '+troubleTicket.Service_Zip_Code__c);
                for(Account acc: lstServiceAddress){
                    if(acc.id == SelectedServiceAddress){
                        troubleTicket.Service_Zip_Code__c = acc.Service_Location_Postal_Code__c;
            List<Case> ttList = new List<Case>{troubleTicket};
            List<Database.saveResult> srList = Database.insert(ttList);
            for (Integer i=0;i<srList.size();i++) {
                Database.SaveResult sr = srList.get(i);
                Case relatedCase = new Case();
                    relatedCase = ttList.get(i);
                    cmt = new CaseComment();
                    cmt.ParentId = relatedCase.id;
                    cmt.CommentBody = relatedCase.Description;
                    if(relatedCase.Status_Type__c=='Dispatched Out'){
                        tas.Trouble_Ticket__c = relatedCase.id;
            if(lstCmt.size()>0 && lstCmt!=null){
                insert lstCmt;
            if(lstTAS.size()>0 && lstTAS!=null){
                insert lstTAS;
        catch(Exception e)
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());

When i clicked on Submit button this will call one method called saveandsubmit , plz refer the method code in code sample.

Please help me to resolve this issue . Thanks in advance.
Hi Team,

Is there any possible to create a validation rule for stoping task creation when Opportunity stage = completed ?. If yes please help us.

Thanks in Advance

  • August 05, 2016
  • Like
  • 0

  I am creating a web to lead form. In that form i am using picklist filed. I want to make this picklist field required on visualforce page. I am not able to do it using required ="true". What will be other solution.

<section class="form-row">
<label for="Interested In">Interested In:</label>
<section class="select-outer">
<select class="select" id="00N36000006Q84K" name="00N36000006Q84K" title="Interested In" required="true">
<option value="">Please select</option>
<option value="Mobile Apps">Mobile Apps</option>
<option value="Web Apps">Web Apps</option> <option value="Salesforce">Salesforce</option>
<option value="Technical Support">Technical Support</option>
<option value="Application Support">Application Support</option>
Hi all,

please find the image when i am clicking the search button then display the serched number records in visualforce page please helpUser-added image
  • July 18, 2016
  • Like
  • 1
I need a test code for this pagereference method ..its with for loops and if conditions..so help me to findout this.
Thanks in advance.
public PageReference Del (){
        Integer dmlrows = Limits.getLimitDMLRows();
        Integer curdmlrows = Limits.getDMLRows(); 
        Integer remainingdmlrows = dmlrows - curdmlrows;
        Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index'));  
        if (newRFPProdList.get(indexVal - 1).id!=null)
            delRFPProdList.add(newRFPProdList.get(indexVal - 1));
        Id prodid = newRFPProdList.get(indexVal - 1).Product__c;  
        delete [select ID from rfp_question__c where rfp__c = :rfpID and product__c =: prodid];
        remainingdmlrows = dmlrows - curdmlrows;
        newprd.remove(indexVal - 1);
        newRFPProdList.remove(indexVal - 1);
            delete delRFPProdList;
        catch (Exception e) {
          String  message  = '[ PACRES ] Exception: ' + e.getMessage() + '; line: ' + e.getLineNumber() ;
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, '[ PACRES ] Exception: ' + e.getMessage() ));
            exceptionMessages += message + '\n\n';
        return null;
What is the difference between fast update and records update in flows ? 
1) when we should use Fast Update & when we should use Records Update .
2) Benifits of each one .

Soumya Ranjan+