• Swaraj Behera 7
  • NEWBIE
  • 95 Points
  • Member since 2015
  • Salesforce Developer
  • Accenture


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 3
    Questions
  • 65
    Replies
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?
Hi,
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]){


  a.ParentId=Trigger.new[0].ConvertedOpportunityId;
  System.debug('parentid' +a.ParentId);

  lstattach.add(a);
}

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
hi

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


Thanks
aqleem
  • 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:
@RestResource(urlMapping='/abc/xyz/*')
global class MyClass{

    @HttpPost
    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());
       }
    } 
}
Hello,
as i wrote in the title i've got this issue. the two classes i use are those:
@isTest
public class ContainsProvaTest {
    static testMethod void prova(){
        ContainsProva prova1 = new ContainsProva();
        prova1.contains();
        
    }
}

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.

Configuration

test configuration

What's wrong with that?

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

Thanks

Rossella
public with sharing class LP_CreateNewCasePage_Controller 
{

public String Id;
public Id ParentId;
public id selectedrecordtype;
 public PageReference OtherRedirect(){
   
    try{
           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();
   
                if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
                {
                ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
                Id=(string)ParentId;
                if(Id.Startswith('003')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                    }
                if(Id.Startswith('001')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);               
                    }
                return p;
                }

                else{
                
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                return p;

                }
   }
   catch(Exception l_objEx)
        {            
            String l_stMsg = 'Exception while redirecting to Case Creation Page.';
            String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
            System.debug(l_stErrMessage);
            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() {
        
        if(cmMap.containsKey(selectedcm))
        {
            Call_Meeting__c tempMeeting = cmMap.get(selectedcm);
            tempMeeting.Treating_Unit__c = tuId;
            update tempMeeting;
            return (new PageReference('/'+tuId));
        }
        else
        {
            return null;
        }
    }        
}

Test class 

@isTest
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');
        uopAccountId=uoprt.getRecordTypeId(); 
       
        ContactRecordType__c rectype = new ContactRecordType__c();
        rectype.Name='UOP_AccountRecordType';
        rectype.UOP_Account_RecordType__c=uopAccountId;
        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';
        up.UOP_Business__c=p.id;
        insert up;
        
        sales_district__c sd=new sales_district__c();
        sd.Name='INDIA';
        insert sd;
        system.debug('*******sales district********'+sd);
        
        Uop_geo_region__c ur=new Uop_geo_region__c ();
        ur.Name='INDIAN SUBCONTINENT';
        insert ur;
        system.debug('*******Uop_geo_region__c********'+ur); 
        
        SAP_Customer_Info__c testcustomer = new SAP_Customer_Info__c();       
        testcustomer.Name='100462';
        testcustomer.UOP_Company_Name__c='AGIPPETROIL SPA';
        testcustomer.UOP_Geographic_Region__c='EUR';
        testcustomer.UOP_Sales_District__c=sd.id;
        testcustomer.UOP_Geo_Region__c=ur.id;
        testcustomer.UOP_Address1__c='DEVKARAN MANSION IIND FLR';
        testcustomer.UOP_Address2__c='79 PRINCESS STREET';
        testcustomer.UOP_City__c='Hyderabad';
        testcustomer.UOP_Honeywell_Geo_Region__c='India';
        testcustomer.UOP_Country__c='INDIA';
        insert testcustomer; 
        system.debug('*******testcustomer********'+testcustomer);     
        
         
        Country__c c=new Country__c();
        c.Name='INDIA';
        c.Region__c='India';
        insert c;
        
        Account acc=new Account();
        acc.Name='Test Name';
        //acc.UOP_Delta_Type__c='Agent';
        acc.RecordTypeId=uopAccountId;
        acc.Sales_District__c=sd.id; 
        acc.SAP_Customer_Info__c=testcustomer.id;                
        acc.BillingStreet ='sfdc';
        acc.BillingState ='sfdc';
        acc.BillingCountry ='INDIA';
        acc.BillingPostalCode='12221';
        insert acc;
        system.debug('Account.country'+acc.BillingCountry);

        acc= [Select OwnerID, Owner.ID From Account where ID = :acc.id];
        system.assertNOTEquals(null,acc.OwnerID);
        system.assertNOTEquals(null,acc.Owner.ID);
        
        Treating_Units__c TU = New Treating_Units__c ();
        TU.Account__c=acc.ID;
        TU.Unit_Reference_number__c='D-206';
        TU.Contaminants_Removed__c='H2O';
        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);
        CM.Meeting_Location__c='Teleconference';
        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();
        req.setAction('Removed');        
        req.setWorkitemId(piwi.get(0).Id);
   
        Approval.process(req,false);
    }
}




{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 


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

sforce.apex.execute("approvalRecall","recallApproval",{ID:"{!Quote.Id}"}); 
alert("Approval has been recalled"); 
window.open('/{!Quote.Id}'); 

else 

alert("Recall Cancelled"); 
}{!Quote.Id}
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];
                            
if(Trigger.isInsert){
   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;     
        taskList.add(t);
    }
}
//Update 
if(Trigger.isUpdate){
    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;
        
            taskList.add(t);
         }
    }
   }
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.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        SendmailUtils.Emailtemplate emailtmp=new SendmailUtils.EmailTemplate();
        emailtmp.emailTemplate=bdy.escapeHtml4();
        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';
        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&To='+too+'+&Bcc=&contacts='+JSON.serialize(Contactlists)+'&Body='+JSON.serialize(emailtmp)+'&contents='+JSON.serialize(contentCategoryIDs)+'&IsQueue='+isQue); 
      
        try {
            res = http.send(req);
     
            if (res.getBody() != null) {
                if(isQue=='0')
                {
                    List<SendmailUtils.EmailTemplateListData> emailLists=new List<SendmailUtils.EmailTemplateListData>();
                    emailLists=(List<SendmailUtils.EmailTemplateListData>)json.deserialize(res.getbody(),List<SendmailUtils.EmailTemplateListData>.class);
                    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>();
                            sendTo.add(emailData.To);
                            // System.debug ( 'emailData.To' +emailData.To);
                            emails.setToAddresses(sendTo);
                            emails.setSubject(emailData.Subject);
                            if(emailData.Body!=null)
                            emailData.Body = emailData.Body.unescapeHtml4();
                            emails.setHtmlBody(emailData.Body);                         
                            emails.setReplyTo(userEmail);

        -----------:  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  );
                                }        
                            }

 
Hi,

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.
HI,
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,


thanks,
NAGARJUNA REDDY NANDIREDDY
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!');
  
  
  
  }
 
</script>
  
  <apex:form >
  
  
  <apex:actionFunction name="f1"   action="{!m1}"  />
  <apex:commandButton value="enter"  onclick="f1"     />
  </apex:form>
  
</apex:page>


Controller:

Public class bang1
{

Public void m1()
{

System.debug('hiiiiiiii');



}

}

Pleasesuggest me.

Regards,
Siva

 
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='';
        try{                    
            if(lstSelectedProviProduct!=null && lstSelectedProviProduct.size()>0)
            {
                for(SelectionWrapper wrapper : lstSelectedProviProduct)
                {                  
                  
                    strOli += getSemiColonValid(wrapper.RecordId);
                    system.debug('--->>>'+strOli);
                }
            }
            troubleTicket.Selected_Order_Line_Items__c=strOli;

            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);
            }
            else{
                for(Account acc: lstServiceAddress){
                    if(acc.id == SelectedServiceAddress){
                        troubleTicket.Service_Zip_Code__c = acc.Service_Location_Postal_Code__c;
                        break;
                    }
                }
            }           
            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();
                if(sr.isSuccess()){
                    relatedCase = ttList.get(i);
                    cmt = new CaseComment();
                    cmt.ParentId = relatedCase.id;
                    cmt.CommentBody = relatedCase.Description;
                    lstCmt.add(cmt);
                    if(relatedCase.Status_Type__c=='Dispatched Out'){
                        tas.Trouble_Ticket__c = relatedCase.id;
                        lstTAS.add(tas);
                    }
                }
            }
            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());
            ApexPages.addMessage(msg);
            system.debug(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
Hello,

  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>
</select>
</section>
</section>
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
Hi,
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;  
        system.debug('selectedprodid'+prodid);
        try{
        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);
        
        if(delRFPProdList.size()>0)
            delete delRFPProdList;
        delRFPProdList.clear();
        }
        catch (Exception e) {
          String  message  = '[ PACRES ] Exception: ' + e.getMessage() + '; line: ' + e.getLineNumber() ;
            //ApexPages.addMessage(message);
            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 .

Regards,
Soumya Ranjan+