• Abhishek_DEO
  • SMARTIE
  • 633 Points
  • Member since 2015

  • Chatter
    Feed
  • 20
    Best Answers
  • 0
    Likes Received
  • 6
    Likes Given
  • 0
    Questions
  • 117
    Replies
I am doing the challenge for Reports in ADM beginner.  I messed up my report example so I wanted to start from scratch.  I deleted the report and tried to create a new one with the same name.  The system does not allow me to do that as it is saying that the name is already in use.  In order to pass the challenge, I need to have the pre-determined report name.  Any help please...............
Why i am getting this error , and what it wants to tell me exactly...
trigger duplicateTriggeronPosition on Position__c (before insert, before update) {
    for(Position__c pos:Trigger.new){    
    List<Position__c> posRec=[select id from Position__c where Name=:pos.Name];
        if(posRec.size()>0){
            posRec.Name.addError('You Are entering duplicate name');
        }
}
}
Hi ,

My requirement is to get the pop up when i click on the enter  in VF page. in  the belwo code  controller methos is being  called, but alert  pop up is not coming when i click on the enter. Code  is  below,

VF CODE:
<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(); return false;"      />
  </apex:form>
  
</apex:page>

Apex:

Public class bang1
{
Public bang1()
{
System.debug('hiiiiiiiiiii');

}

Public void m1()
{

System.debug('hiiiiiiiiiiiiii');




}

}

Regards,
siva.



 
Hi.
I have some issue for several accounts, after done some changes in the roles.
For some accounts the users cannot create new opportunity. They getting message of 'Insufficient privileges' after clicking save in the opportunity layout.
I checked and the users have access thru the sharing on the specific accounts (+they have Read/Write on the related opportunity/cases), they have access in their profiles. For some cases it happen also for the account owner.

Any idea what else could be the reason?

Thanks.
Why there is two object get created when I create any cutom object? What is the exact use of history object? when we're using this object? What are some things that we must remember while using this object? Please guide.
Hi,
I have set the default value checkbox to TRUE, it works fine in standard edit page, however when we use custom VF page for create the record, the checkbox won't set to default values.
<apex:inputCheckbox value="{!account.TestCheckbox__c}"/>
My requirement is what default value configured in field configuration should be display in custom page dynmaically , hence selected ="true" attribure not helpful in my requirement.
Do you know how to display the default values of checbox in VF page?

Appreciate your response.
Thanks,
Hareesh
Hi Everyone,

I have got a class that sends an email and it works really well adding the files from the related notes and attachments. However, I would also like to include a file from the documents object.
This file will have a fixed id of 015D0000003rgYq

I tried something like this, but cannot get it to work:
Document doc = [SELECT Id FROM Document WHERE Id = '015D0000003rgYq'];

How can I reference this in my code and then get it to attach both files from the different objects?

A sample of the code I currently have is:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
     List<String> toaddress = new List<String>();
	 toaddress.add(string.valueof(cf.Email_to_send_confirmation_to__c));
        mail.settoaddresses(toaddress);
        mail.setReplyTo('trainingbookings@certsure.com');
        mail.setSenderDisplayName('Certsure Training');
        mail.setBccSender(false);
        mail.setUseSignature(false);
        mail.saveAsActivity = true;
     	mail.setSubject(subject);
     	mail.setHtmlBody(htmlBody);
        
      //Set email file attachments
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Id, Name, Body, BodyLength from Attachment where ParentId = :oppr])
        {
     // Add to attachment file list
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        efa.setFileName(a.Name);
        efa.setBody(a.Body);
        fileAttachments.add(efa);
        } 
        mail.setFileAttachments(fileAttachments);
      //Send email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        return null;
Hello,

I just use the right function to cut a string as is shown in the code below, the modified line is bold, the program works very well in the sand box, but when I deploy on the production environment I get a NullPointer error message on the modified line.

Thank you for your help

public without sharing class Ctrl001_NouveauProspect {
    public string keyword {set;get;}
    public string firstName{set;get;}
    public string lastName{set;get;}
    public string phone{set;get;}
    public string email{set;get;}
    public string CIN{set;get;}
    public boolean AddButton {set;get;}
    public boolean SearchResultButton{set;get;} 
    public boolean SearchResultLeadsButton{set;get;} 
    public boolean SearchResultAccountsButton{set;get;} 
    public boolean creationbutton{set;get;}     
    public Account [] accounts{set;get;}
    public List<Account> ResultListAccount{set;get;}
    public List<Lead> ResultListLead{set;get;}
    public Lead[] leads{set;get;}
    String accountQureyString ;
    String LeadQureyString ;

    
    
    public Account acc {set;get;}
    public Lead piste {set;get;}
    
    public Id accId {set;get;}
    public Id pisteId {set;get;}
    
    public Ctrl001_NouveauProspect(ApexPages.StandardController controller) {
        ResultListAccount = new List<Account>();
        ResultListLead = new List<Lead>();
    

    }
    public Ctrl001_NouveauProspect() {
    
    AddButton = false;
    SearchResultButton =false;
    SearchResultLeadsButton =false;
    SearchResultAccountsButton=false;
    creationbutton=false;
    }
    
    public PageReference createProspect() {

        string url = '/001/e?retURL=%2F001%2Fo';

        if(firstName != null) {
                  url  = url + '&name_firstacc2=' + firstName ;
        }
        if(lastName != null) {
                  url  = url + '&name_lastacc2=' + lastName ;
        }        
        if(phone != null) {
                  url  = url + '&acc10=' + phone ;
        }
        if(email != null) {
                  url  = url + '&PersonEmail=' + email ;
        }
        if(CIN != null) {
                  url  = url + '&00N24000009s6qi=' + CIN ;
        }
        return new Pagereference(url);
}
    
    public PageReference search(){
        AddButton = false;
        ResultListAccount = new List<Account>();
        ResultListLead = new List<Lead>();
        creationbutton=false;
        string phone_like = '%'+phone.right(9)+'%';
     System.debug('##KeyWord##'+keyword);
    if(CIN != null && CIN.contains(' '))
    {Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.WARNING,'Merci de saisir un CIN sans espaces'));}
    
    //if(keyword!=null && keyword!=''){
    System.debug('firstName'+firstName+'lastName'+lastName+'phone'+phone+'CIN'+CIN);
   // List<List <sObject>> myQuery = search.query(SOSL_search_string);
   
   // String searchquery='FIND\''+firstName+' '+lastName+' '+phone+' '+CIN+' *\'IN ALL FIELDS RETURNING Account(id,FirstName,LastName,Phone,N_piece_cni__c), Lead(id,FirstName,LastName,Phone)'; 
  
                   // 'SELECT Id FROM MyCustomObject__c WHERE field1__c = :myVariable.field1__c';   
      accountQureyString ='SELECT a.firstName, a.lastName, a.phone,a.PersonEmail, a.CIN__c from Account a WHERE ID !=null ';
      if(firstName!=null && firstName!='')
      { accountQureyString+='AND (a.firstName =: firstName OR a.lastName =: firstName)'; }
      if(lastName!=null && lastName!='') 
      {accountQureyString+='AND (a.lastName =: lastName OR a.firstName =: lastName)';}
      if(phone!=null && phone!='')
      //{ accountQureyString+='AND (a.phone =: phone OR a.PersonMobilePhone=: phone ) ';}
      { accountQureyString+='AND (a.phone like :phone_like OR a.PersonMobilePhone like :phone_like ) ';}
      if(CIN!=null && CIN!='') 
      {accountQureyString+='AND a.CIN__c=: CIN ';}
      if(email!=null && email!='') 
      {
       accountQureyString+='AND a.PersonEmail =: email ';}
       accountQureyString+=' limit 20';
      System.debug('accountQureyString'+accountQureyString);
   
   
  
    
    
    leadQureyString ='SELECT a.firstName, a.lastName, a.phone, a.Email from Lead a WHERE ID !=null ';
    
     if(firstName!=null && firstName!='')
      { leadQureyString+='AND (a.firstName =: firstName OR a.lastName =: firstName)'; }
      if(leadQureyString!=null && lastName!='') 
      {leadQureyString+='AND (a.lastName =: lastName OR a.firstName =: lastName)';}
      if(phone!=null && phone!='')
      { leadQureyString+='AND (a.phone =: phone OR a.MobilePhone =: phone OR a.Fax =: phone)';}
      if(email!=null && email!='') 
      {leadQureyString+='AND a.Email =: email ';}
      leadQureyString+=' AND IsConverted = false limit 50';
      
    
   //String searchquery='FIND\''+firstName+' '+lastName+' '+phone+' '+CIN+' *\'IN All Fields RETURNING Account(id,FirstName,LastName,Phone,CIN__c), Lead(id,FirstName,LastName,Phone)'; 
   //System.debug('##searchquery'+searchquery);
    if((firstName!=null && firstName!='') || (lastName!=null && lastName!='') || (phone!=null && phone!='') || (CIN!=null && CIN!='') || (email!=null && email!=''))
    {ResultListAccount = Database.query(accountQureyString);}
    if((firstName!=null && firstName!='') || (lastName!=null && lastName!='') || (phone!=null && phone!='') || (email!=null && email!=''))
    {ResultListLead = Database.query(leadQureyString);}
    System.debug('##ResultListAccount'+ResultListAccount);
    System.debug('##ResultListLead'+ResultListLead);
   //List<List<SObject>>searchList=search.query(searchquery);
    
    
    //accounts = ((List<Account>)searchList[0]);
    //leads = ((List<Lead>)searchList[1]);
    //System.debug('accounts'+accounts);
    //System.debug('leads'+leads);
    
    if(ResultListAccount != null ||ResultListLead != null /*ResultListAccount.size()>0 ||ResultListLead.size()>0*/){
    SearchResultButton=true;
    }
    
    if(ResultListAccount != null && (ResultListLead == null|| ResultListLead.size()==0)/*ResultListAccount.size()>0*/){
    SearchResultAccountsButton=true;
   }
   if(ResultListLead != null /*ResultListLead.size()>0*/){
   SearchResultLeadsButton=true;
   }
   if ((CIN!=null && CIN!='')||(phone!=null && phone!='')|| (email!=null && email!='')){
   AddButton=true;
   }
  //  }
   if(ResultListAccount.size() == 0 && ResultListLead.size() == 0)
   {creationbutton=true;}
    
   
    //}
    return null;
    }
    
    public PageReference addtoaccountteam(){
       
     system.debug('>>>>>>>>>'+accId);
       
     AccountTeamMember[] newmembers = new AccountTeamMember[]{};  //list of new team members to add
     AccountShare[] newShare = new AccountShare[]{};  //list of new shares to add
     User currentuser =  [select id,name,department from user where id=:UserInfo.getUserId() LIMIT 1];  //get the user running the trigger, anyone that changes the Account will added to the account team
     ID uid=currentuser.id;
     String dept=currentuser.department;

          AccountTeamMember Teammemberad=new AccountTeamMember();
          Teammemberad.AccountId=accID;
          Teammemberad.UserId=uid;
          //Teammemberad.TeamMemberRole = dept;
          Teammemberad.TeamMemberRole = 'Commercial';
          newmembers.add(Teammemberad);

     Database.SaveResult[] lsr = Database.insert(newmembers,false);//insert any valid members then add their     entry if they were successfully added
     Integer newcnt=0;
     for(Database.SaveResult sr:lsr){
    if(!sr.isSuccess()){
        Database.Error emsg =sr.getErrors()[0];
        system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
    }else{
        newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Edit',OpportunityAccessLevel='Edit',CaseAccessLevel='Read'));
    }
    newcnt++;           
     }
     Database.SaveResult[] lsr0 =Database.insert(newShare,false); //insert the new shares
     Integer newcnt0=0;
     for(Database.SaveResult sr0:lsr0){
    if(!sr0.isSuccess()){
         Database.Error emsg0=sr0.getErrors()[0];
         system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0);
    }
    newcnt0++;
     }
     
     
     return new PageReference('/'+accId);
        }  
}


User-added image
Hi All

While creating a record from Candidate object to emplyee object using custom button on click on javascript behavior. I got the following error.

A problem with the onclick javascript encountered unexpected number.

Code is here

{!REQUIRESCRIPT('/soap/ajax/36.0/connection.js')}

 
var emp = new sforce.SObject('Employee__c');

 emp.Employee_First_Name__c =  {!Candidate__c.First_Name__c};
emp.Employee_Last_Name__c = {!Candidate__c.Last_Name__c};
emp.Mobile_No__c = {!Candidate__c.Mobile_No__c};
emp.Personal_Email__c = {!Candidate__c.Email__c};
emp.Employee_Address1__c = {!Candidate__c.Address1__c};
emp.Employee_Address2__c = {!Candidate__c.Address2__c};
emp.City__c = {!Candidate__c.City__c};
emp.State__c = {!Candidate__c.State__c};
emp.Zip_Postal_Code__c = {!Candidate__c.Zip_Postal_Code__c};


  
result = sforce.connection.create([emp]);

 
if(result[0].success == 'true')
{
    alert('A New Employee with Name - ' + emp.Eismployee_First_Name__c + ' was Created Successfully.');
}

Any one help on this... I am very new to salesforce and javascript... pls help on this


 
Hi ,

I have a requirement where I need to display a vf page as pop -up  on button click on case and the vf page would include some text questions and once these are answered and user clicks on save button , then these text values should be inserted as a new comment to that particular case.

I have started working on this but when I create a new case comment by supplying required fields Parentid and commentbody. It throws me an error : Parentid doesn't exist or some time commentbody doesn't exists.

Can someone please help me....


Error: test Compile Error: Variable does not exist: CommentBody at line 13 column 8

public with sharing class test 
{
    public string text {get;set;}
    private CaseComment c ;
    
    public test ()
    {
        c = new CaseComment ();
    }
   public PageReference save() 
   {
       c = new CaseComment();
       c.CommentBody = text ;   ***** error *********
       c.ParentId = '5009000000dza7i';
       insert c ;
        
        return null;
   }

    
    
    
}
 
  • June 10, 2016
  • Like
  • 0
Hi all,

I have a problem with this challenge : 

Write an Apex trigger that fires before records are inserted and ensures that the ShippingState field has the same value as the BillingState field.
Create an Apex class named AccountTriggerHandler that contains a public static method called CreateAccounts to accept the List of Account objects.
For each Account record, before saving, ensure that the ShippingState field has the same value as the BillingState field.
Write an Apex trigger named AccountTrigger that fires before records are inserted.
The Apex trigger must call the AccountTriggerHandler.CreateAccounts() method with the collection of new records.
Create a test class named AccountTriggerTest that inserts 200 Account records with a BillingState of CA. After the insert, test to ensure that all 200 records have a ShippingState of CA.
Before verifying this challenge, run your test class at least once using the Developer Console Run All feature.

and this is my classes :
 
public class AccountTriggerHandler {
    
    public static void CreateAccounts(List<Account> acclist){
        
        
        for(Account a:acclist){
            
            if(a.ShippingState!=a.BillingState){
                a.BillingState=a.ShippingState;
              
            }
        }
    }

}
 
trigger AccountTrigger on Account (before insert) 
{
    if (Trigger.isBefore && Trigger.isInsert) {
			AccountTriggerHandler.CreateAccounts(Trigger.new);
		}	
	}
 
@isTest
public class AccountTriggerTest {
    
    @isTest static void TestCreate200Records(){
        
        // Test Setup data
        // Create 200 new Accounts
        List<Account> accts = new List<Account>();
        for(Integer i=0; i < 200; i++) {
            Account acct = new Account(Name='Test Account ' + i, BillingState = 'CA');
            accts.add(acct);
        
            Test.startTest();
            //insert acct;
        	Test.stopTest();
            
            for (Account a:accts){
                
                System.assertEquals('CA', a.ShippingState, 'ERROR');
            }
            
    }

        
}
}
And this error :
Challenge Not yet complete... here's what's wrong: 
The 'AccountTrigger' Trigger does not appear to be working correctly. Inserted records did not have matching BillingState and ShippingState values.

Anyone can help me please??
Thanks!
 
When i deployed my Domain to users, i received the following error while testing lightning apps.

An error has occurred in the following section: [Exception, DomainNotPropagated]. Salesforce.com has been notified of this error.
An error has occurred in the following section: [Exception, DomainNotPropagated_desc]. Salesforce.com has been notified of this error.

Can anyone help?
Hello,

I have a security related issue here. Let me explain how I tried to reproduce the issue in my developer org I faced during a project:

I defined two users, one with CEO role and other with Worker role. Obviously, the CEO is above the Worker in hierarchy. 

I defined three simple objects; ObjectA is the child of both ObjectX and ObjectY. I created the Master-Detail relationship between ObjectX and ObjectA first, therefore I expect ObjectA records to inherit the ownership from ObjectX according to SFDC documentation. Moreover, ObjectX and ObjectY possess a Private org-wide sharing setting.
  • Test 1: CEO creates ObjectX record. Worker creates ObjectY record. CEO creates ObjectA record (Worker can't create because it won't see the ObjectX record created by CEO). I expect the Worker to not see the ObjectA record, and I couldn't see. That's OK.
  • Test 2: Worker creates ObjectX record. CEO creates ObjectY record. CEO creates ObjectA record. I expect the Worker to see the ObjectA record, and I couldn't see. This is unexpected, I should have had access to the ObjectA record.
The sayings in documentation regarding ownership inheritance in junction objects simply contradicts with this test outcome here. Could anyone point me out the possible mistake in my methodology here? Am I missing something? 

Thanks in advance.
 
We use web2lead form to submit lead from our website, but it would be fail sometime due to browser tracking protection or other reason.
So we decide to add the lead via background process, not from foreground like using ajax 
Is there a dll or api or web service that our partner can use to add the lead to saleforce ?
We have provide some info at setup/Build/Develop/api.  But our partner said it does not help.
Please give us some advice, Thanks

 
I have two checkboxes  in a row in pageblocktable.If i check one,the other should be automatically checked and if unchecked other checkbox should be unchecked.Dont know how to do it in pageblocktable.Please help me how to do this?
Hello Everybody,
How to create Visualforve of Controller extension with Custom Controller not with StandardController.

Thanks.
APEX CLASS

public class  ViewContacts 
{
    public List<contact> acc{get;set;}
    
    public ViewContacts (){
    searchresult();
    }
   
Public void searchresult(){
           SYSTEM.DEBUG('Number of records '); 
    acc = [SELECT Name,lastName,phone,id FROM Contact WHERE name != null LIMIT 999 ];
}


}



VF PAGE

<apex:page standardController="Account" >
<apex:form >
   <apex:pageBlock title="Hello {!$User.FirstName}!">
      You are viewing the account.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
      
      <apex:pageBlockTable value="{!acc}" var="con">
              
      <apex:column value="{!con.Name}" />
         <apex:column value="{!con.Email}"/>
         <apex:column value="{!con.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
   </apex:form>
</apex:page>
I am working with a trigger, apex and a visualforce page,
trying to display in my vfpage the error of duplicate values, and it works kind of.
The error message appears in my visual, but it is giving me all the records created in my Factura__c
and not the one of duplicate value. I think is because my trigger it not working well
Example:

In the top of my visual is showing me 3 errors and that is because there 3 records created in my Factura__c
and the only one that it should be displaying it is in the red box.

My object is Factura__c and the custom field that it should not have duplicate values is called Pre_impreso_001_001__c

User-added image


my trigger
trigger MensajeValorDuplicadoCentro on Factura__c (before insert, before update) {

    Map<Decimal, Factura__c> facMap = new Map<Decimal, Factura__c>();

    For (Factura__c factura : System.Trigger.new) {     
        If ((factura.Pre_impreso_001_001__c != null) && (System.Trigger.isInsert ||
        (factura.Pre_impreso_001_001__c != System.Trigger.oldMap.get(factura.Id).Pre_impreso_001_001__c))){            
            facMap.put(factura.Pre_impreso_001_001__c, factura);                
        }                  
    }
  

    For (Factura__c factura : [SELECT Id, Name, Sucursal__c FROM Factura__c]) {  		
        If (factura.Sucursal__c=='Maker Centro'){      	
            For (Factura__c facturace : [SELECT Pre_impreso_001_001__c FROM Factura__c WHERE Pre_impreso_001_001__c IN :facMap.KeySet()]) {                                                                
                Factura__c newFactura = facMap.get(facturace.Pre_impreso_001_001__c);                  
                newFactura.addError('El #Pre-Impreso(001-001) ingresado ya fue utilizado en la Factura:<a href=\'https://cs21.salesforce.com/'+factura.Id+'\'>'+factura.Name+'</a>', false);           
            }       	
        } 
    } 

}


my visual
<apex:page controller="FacturaRapidaController" tabStyle="Factura__c">  
    <script>     
    function confirmarCancelar() {           
        var isCancel = confirm("Estas seguro que desea cancelar la creación de Factura?");        
        if (isCancel)return true;    
        return false;
    } 
    </script>     
    <apex:sectionHeader title="Creación de" subtitle="FACTURA"/>                  
    <apex:form >      
        <apex:pageBlock mode="edit" title="Crear Factura Contado">                
                         
          	<div style="font-size: 12px; color:#FF0000;">                                                                                              
        		<apex:pageMessages id="errMessages" escape="false"/>                                                                  
    		</div>    
            <apex:pageBlockButtons >                          
                <apex:commandButton action="{!guardarFactura}" value="Guardar"/>                                
                <apex:commandButton action="{!cancelarFactura}" value="Cancelar" onclick="return confirmarCancelar()" immediate="true"/>                      
            </apex:pageBlockButtons> 
            
            <apex:pageBlockSection title="Información Básica de la Factura" columns="1">                                     
                <apex:inputField value="{!factura.Pre_Factura__c}"/>                 
                <apex:inputField value="{!factura.Sucursal__c}" required="true"/>                
                <apex:inputField value="{!factura.Caja__c}" required="true"/>                        
                <apex:inputField value="{!factura.Serie__c}" required="true"/>                
            </apex:pageBlockSection>   
                                 
            <apex:pageBlockSection title="Confirmar Factura" columns="1">            
                <apex:inputField value="{!factura.Pre_impreso_001_001__c}"/>                                                                                                                  
            </apex:pageBlockSection>                                      
        </apex:pageBlock>       
    </apex:form>
</apex:page>



my apex
public PageReference guardarFactura(){                  
        try{ 
            insert factura; 
        }
        catch(exception ex) {  
            ApexPages.addMessages(ex);
            return null;
        }

        PageReference FacturaRapidaPage = new ApexPages.StandardController(factura).view();
        FacturaRapidaPage.setRedirect(true);
        return FacturaRapidaPage;
    }




 
Hi Friends,
I am getting following bug while testing my controller "System.QueryException: line 6:730 no viable alternative at character 'a' ". Can any one help how to resolve it. Can any one tell me is the following query is correct or not if it is wrong modify the query and give me reply as correct query your help is really appreciable. I hope i receive reply.
In the following query i am passing SiteIds, procedures and patientage as a string of values dynamically but they are not passed to the query.
I ahve written the query like this
 conditionQuery =     ' AND Patient__r.IsActive__c = true ' +
                             ' AND Patient__r.Site_Id__c IN : siteIds ' +
                             ' AND Patient__c IN : patEnrollTeamIds' +
                             ' AND Patient__r.Patient__r.Gender__c IN : gender ' +
                             ' AND Patient__r.Patient__r.Age_Group__c IN : patientAge ' +
                             ' AND Patient__r.Surgery_Type__c IN : procedures ' +
                             ' AND Patient__r.ASA_Score__c IN : asascore ';

This is debug log:
Final Query :Select Text_Field__c, Patient_Survey__r.Patient__r.Id, Patient_Survey__r.Patient__r.Patient__r.First_Name__c, ER_DOS_Delta__c, Patient_Survey__r.Patient__r.Patient__r.Last_Name__c,LOS__c, Patient_Survey__r.Patient__r.Surgery_Date__c,Number__c, Patient_Survey__r.Patient__r.Surgery_Type__c,Patient_Survey__r.Patient__r.ASA_Score__c, Patient_Survey__r.Patient__r.Patient_Enrollment_Status__c, Patient_Survey__r.Patient__r.Percent_Survey_Completed__c,Patient_Survey__r.Patient__r.Missed_Surveys__c,Patient_Survey__r.Patient__r.Other_Pain_Management_used_if_any__c From Patient_Responses__c WHERE Number__c != null AND IsDemo__c =false AND Question_Pattern__c = 'Group' AND Group_Name__c = 'Pain' AND Patient_Survey__r.Survey_Status__c IN ('Completed', 'In-Progress' , 'Expired') AND Category__c LIKE '%Rest%' AND Patient_Survey__r.Name= 'Post Surgery, day 3' AND Patient_Survey__r.Patient__r.Patient__r.Account__c in :siteIds AND Patient_Survey__r.Patient__c IN : patEnrollTeamIds AND Patient_Survey__r.Patient__r.Surgery_Type__c in :procedures AND Patient_Survey__r.Patient__r.Patient__r.Age_Group__c in :patientAge AND Patient_Survey__r.Patient__r.Patient__r.Gender__c in :gender AND Patient_Survey__r.Patient__r.ASA_Score__c IN : asascore AND DAY_ONLY(Createddate) <=2017-08-10 00:00:00and DAY_ONLY(Createddate) >=2017-01-10 00:00:00 ORDER BY Patient_Survey__r.Name LIMIT 1000
 global class SelectedFilters{
        public Set<String> SiteIds{get;set;}
        public Set<String> surgeonIds{get;set;}
        public Set<string> anesthesiologistIds{get;set;}
        public List<String> procedures{get;set;}
        public List<string> ONQUsed{get;set;}
        public List<string> patientAge{get;set;}
        public List<string> gender{get;set;}
        public string onload {get;set;}
        public List<string> PainManagementUsed{get;set;}
        public List<String> HospitalName {get;set;}
        public List<String> ASAScore {get;set;}
        
        public SelectedFilters(Set<String> siteIds, /*Boolean is_ReadOnlySite,*/
                             Set<String> surgeonIds,Set<String> anesthesiologistIds,
                             List<String> procedures,List<string> ONQUsed,
                             List<string> patientAge,List<string> gender,
                             List<string> PainManagementUsed , List<String> HospitalName,List<String> ASAScore) {
            this.siteIds = siteIds;
            this.surgeonIds = surgeonIds;
            this.anesthesiologistIds = anesthesiologistIds;
            this.procedures = procedures;
            this.ONQUsed= ONQUsed;
            this.patientAge= patientAge;
            this.gender= gender;
            this.PainManagementUsed= PainManagementUsed;
            this.HospitalName = HospitalName;
            this.ASAScore = ASAScore;
        }
==
 JSONstring ='{"siteIds":["'+String.valueof(testAccount.id)+
            '"],"surgeonIds":["' +String.valueof(testContact.id)+
            '"],"anesthesiologistIds":["'+String.valueof(testContact.id) +
            '"],"procedures":["Lap BSO"],"ONQUsed":["Yes"],"patientAge":["0-18","18 – 29"],"gender":["Male","Female"],"PainManagementUsed":["ON-Q","Single Injection nerve block","Wound infusion","Local infiltration"],"HospitalName":["ABC","DEF"],"ASAScore":["I"]}';
      
 if(String.isNotBlank(jsonString))
        {
            EngagementGraphsController.SelectedFilters test  = (EngagementGraphsController.SelectedFilters)JSON.deserialize(jsonString,EngagementGraphsController.SelectedFilters.class);
            system.debug('-----------test :'+test);  
            
            EngagementGraphsController.SelectedFilters currentFilter = EngagementGraphsController.generateFilterWrapper(jsonString);
            Set<String> siteIds = currentFilter.SiteIds;
            Set<String> surgeonIds = currentFilter.surgeonIds;
            Set<String> anesthesiologistIds = currentFilter.anesthesiologistIds;
            List<String> procedures = currentFilter.procedures;
            List<string> painMgmntUsed = currentFilter.PainManagementUsed;
            List<string> patientAge = currentFilter.patientAge;
            List<string> gender = currentFilter.gender;
            List<string> hospital = currentFilter.HospitalName;
            List<string> asascore = currentFilter.ASAScore;
     
I am doing the challenge for Reports in ADM beginner.  I messed up my report example so I wanted to start from scratch.  I deleted the report and tried to create a new one with the same name.  The system does not allow me to do that as it is saying that the name is already in use.  In order to pass the challenge, I need to have the pre-determined report name.  Any help please...............
Why i am getting this error , and what it wants to tell me exactly...
trigger duplicateTriggeronPosition on Position__c (before insert, before update) {
    for(Position__c pos:Trigger.new){    
    List<Position__c> posRec=[select id from Position__c where Name=:pos.Name];
        if(posRec.size()>0){
            posRec.Name.addError('You Are entering duplicate name');
        }
}
}
What is the best way to extract deleted opportunities?  Can I rely on the IsDeleted field or should I pull from https://eu2.salesforce.com/services/data/v29.0/sobjects/Opportunity/deleted/?start=2016-07-10&end=2017-12-22 url?  What is the difference?
HI all ,
i m tryiing to create a formula using ISChANGED() Function . but it shows some error..
Can any one help me .
Thank you.
Romil GuptaUser-added image
Hi,

As I want to know count and full name of the searched key.  So I have written the below mentioned code.

But this code shows count properly not full name of the data.  Request you to help me.

list<list<Sobject>> Soslquery = [find 'rakesh*' in all fields returning account(name), f_97__c(name_1__c), contact(firstname)];
// Store the result set into the associated 

list<account> acc= ((list<account>) soslquery[0]);
system.debug('Count of searched word in account object are: '+acc.size());
list<f_97__c> f = ((list<f_97__c>) soslquery[1]);
system.debug('Count of searched word in f.97 object are: '+f.size());
list<contact> con=((list<contact>) soslquery[2]);
system.debug('Count of searched word in contact object are: '+con.size());

if(acc.size()>0)
{
    system.debug('Count of searched word in account object are: '+acc.size());
    for(account e:acc)
     {
     system.debug('Account name is:'+acc.name);
     }
}

if(f.size()>0)
{
    system.debug('Count of searched word in f.97 object are: '+f.size());
    for(f_97__c g:f)
    {
        system.debug('f_97__c name is: '+g.name_1__c);
    }
}

if(con.size()>0)
{
    system.debug('Count of searched word in contact object are: '+con.size());
     for(contact h:con)
     {
     system.debug('Contact name is : '+con.firstname);
     }
}
Hi All,
I am deploying below package from one organization to other organization through ANT tool. I am able to retrieve successfully but while deploying same package I am facing "Error: Not in package.xml" failure.
Package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
	<types>
		<members>Account.curYTDSales__c</members>
        <name>CustomField</name>
    </types>
	<version>36.0</version>
</Package>

Retrieved Metadata is
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>curYtdSales__c</fullName>
        <description>YTD Sales</description>
        <externalId>false</externalId>
        <inlineHelpText>YTD Sales</inlineHelpText>
        <label>YTD Sales</label>
        <precision>18</precision>
        <required>false</required>
        <scale>2</scale>
        <trackFeedHistory>false</trackFeedHistory>
        <trackHistory>false</trackHistory>
        <type>Currency</type>
    </fields>
</CustomObject>
While deploying I am facing below issue.
objects/Account.object (Account.curYtdSales__c) -- Error: Not in package.xml
Please help.
 
Hi ,

My requirement is to get the pop up when i click on the enter  in VF page. in  the belwo code  controller methos is being  called, but alert  pop up is not coming when i click on the enter. Code  is  below,

VF CODE:
<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(); return false;"      />
  </apex:form>
  
</apex:page>

Apex:

Public class bang1
{
Public bang1()
{
System.debug('hiiiiiiiiiii');

}

Public void m1()
{

System.debug('hiiiiiiiiiiiiii');




}

}

Regards,
siva.



 
Hi there,

I have a batch class that checks if a field "Tax ID validation status" is invalid and sends reminder to the Account Owners. My batch basically checks a checkbox and I have a  Worflow rule to trigger email alert when this checkbox is true:

global class InvalidVATReminderBatch implements Database.batchable<sObject>,Schedulable{
 public String query;
    global Database.QueryLocator start(Database.BatchableContext bc){
        return database.getQuerylocator('Select id,Tax_ID_Validation_Status__c,recordtypeId from Account');
    } 
    
   global void execute(Database.batchableContext info, List<Account> accnt){ 
   list<Account>AccList = [Select id,InvalidVATReminder__c,Tax_ID_Validation_Status__c,recordtypeId,recordtype.name from Account where Tax_ID_Validation_Status__c='Invalid'];
   list<Account>saveList = new list<Account>();
   
   if(AccList.size()>0)
   {
   for(Account Acc:AccList)
   {
     if(Acc.Tax_ID_Validation_Status__c=='Invalid')
     {
      Acc.InvalidVATReminder__c=true;
      saveList.add(Acc);
     }
   }
   if(saveList.size()>0)
   {
   try{
     update saveList ;
     }
      catch(Exception e)
     {
      e.getmessage();
     }
   }
  }
 }
  global void finish(Database.batchableContext info)
    {     
    } 
    
    global void execute(SchedulableContext sc) 
    {
      InvalidVATReminderBatch runbatch = new InvalidVATReminderBatch ();  
       ID batchprocessid = Database.executeBatch(runbatch);   
    }
  }

 I have only 20 records that meets this criteria (Invalid status), when I ran the batch it seems to be executing recursively and the same 20 emails are sent out recursively. But the same batch seems to be working well in sandbox, it was executed only once ( received all 20 emails only once). Do you have any idea why the batch was getting executed recursively in Prod?
Here's my batch schedule:
System.schedule('VAT reminder', '0 0 13 4 * ? *', new InvalidVATReminderBatch());

Any help/ ideas would be appreciated.
Thanks
Hi.
I have some issue for several accounts, after done some changes in the roles.
For some accounts the users cannot create new opportunity. They getting message of 'Insufficient privileges' after clicking save in the opportunity layout.
I checked and the users have access thru the sharing on the specific accounts (+they have Read/Write on the related opportunity/cases), they have access in their profiles. For some cases it happen also for the account owner.

Any idea what else could be the reason?

Thanks.
Hi all,
        I write the code for view the list of apex class name in VF page and select and delete the apex class name. But i got the error
Compile Error: DML not allowed on ApexClass at line 12 column 6.  how to fix to solve this error and how to delete the the apex class name in VF page Please help  below is my code...

public class RetrieveClasses{
  
  public void del(){
    List <ApexClass> li=new List <ApexClass>();
     for(sObjectWrapper wrap:wrappers)    
     {
      if(wrap.isSelected){
        li.add(wrap.apx);
      }
     }
     system.debug('dfddddd'+li);
     delete li;
     //li[0].status='Inactive';
    // update li;
    
    }
    
  public void triggerdel(){
   List <ApexTrigger> trggerlist=new List <ApexTrigger>();
   for(sObjectWrapper sobj:wrapp)
   {
      if(sobj.isSelected){
       trggerlist.add(sobj.apt);
       }
   }
   //delete trggerlist;
  }

  public List<sObjectWrapper> wrappers{get;set;}
  public List<sObjectWrapper> wrapp{get;set;}

public RetrieveClasses()
{
  wrappers=getdata();
  wrapp=gettrigger();
}
private List<sObjectWrapper> getdata(){
wrappers = new List<sObjectWrapper>();
for(ApexClass app:[select id,name,apiversion from ApexClass where apiversion=36.0])
{
   wrappers.add(new sObjectWrapper(app,false));
}
system.debug('deleteeeeeeeee===='+wrappers);
return wrappers;
}

private List<sObjectWrapper> gettrigger(){
List<sObjectWrapper> wrapper = new List<sObjectWrapper>();
for(ApexTrigger aptg:[select id,name from ApexTrigger])
{
wrapper.add(new sObjectWrapper(aptg,false));
}
system.debug('trigger values'+wrapper);

return wrapper; 
}
//public boolean isSelected{get;set;}

    public class sObjectWrapper{
    public boolean isSelected{get;set;}   
    public ApexClass apx{get;set;}
    public ApexTrigger apt{get;set;}

    
    public sObjectWrapper(ApexClass apx,Boolean isSelected){
     this.isSelected = isSelected;
     this.apx = apx;
    }
    public sObjectWrapper(ApexTrigger apt,Boolean isSelected){
     this.isSelected = isSelected;
     this.apt= apt;
    }
    
}
}
Why there is two object get created when I create any cutom object? What is the exact use of history object? when we're using this object? What are some things that we must remember while using this object? Please guide.
When deploying task trigger it shows Triggers have 0% code coverage

but the same if we deploy through change set and runts the test class it covers 100% any advise on this please suggect 

here is trigger and test class 

trigger TaskTrigger on Task(before insert) {
    
    if(ACNTriggerSettings__c.getInstance(UserInfo.getUserId()).LG_TaskTrigger__c){return;}
    
    TaskTriggerHandler handler = new TaskTriggerHandler(Trigger.isExecuting, Trigger.size);
        if (trigger.isbefore&& trigger.isinsert) {
            handler.beforeinserttrigger(trigger.new,trigger.newMap);
        }
}
========================
test class 
========================

@isTest(SeeAllData = false)
Public class taskTriggerHandlertest{
static testmethod void addTTControllerTest()  {
   
    test.startTest();
            
    //insert new ACNTriggerSettings__c(SetupOwnerId=UserInfo.getUserid(), LG_TaskTrigger__C=false);
            
    Account testAccount = new Account(Name='testAccountM',BillingStreet='TestStreet', BillingCity='Test City', BillingState='State', BillingPostalCode='12345', BillingCountry='UK');
    insert testAccount;
    system.assertEquals('testAccountM', testAccount.Name);

    Contact testContact = new Contact(FirstName = 'TestNameM', LastName = 'TestNameM', Salutation ='Mr.', email = 'test@test.com',AccountId=testAccount.id);
    insert testContact;
    system.assertEquals('TestNameM', testContact.FirstName);

    Opportunity testOpportunity = new Opportunity(amount=500,CloseDate = system.today().addMonths(4),Approval_Stage4_5__c='Not Submitted', Name = 'TestOppM', StageName = 'Quoting', AccountId =testAccount.id );
    insert testOpportunity;
    system.assertEquals('TestOppM', testOpportunity.Name);
    
    CSCAP__Customer_Approval__c TestCustomerapproval = new CSCAP__Customer_Approval__c(CSCAP__Opportunity__c=testOpportunity.id);
    insert TestCustomerapproval ;
    
    task Testtask = new task (Subject='Customer Approval Received',Status='In Progress',Priority='Medium',type='Other',whatid=TestCustomerapproval.id,OwnerId = UserInfo.getUserid());
    insert Testtask ;
   
    test.stopTest();

}
}

 
I'm creating a Lightning component that uses aura:iterate to dynamically build a form, with a field for each item in a list object. The markup works great, but I don't know how to go back and get the values from the fields later -- to validate the fields and then to save the values.

I would normally use aura:id to component.find() the field, and then get("v.value"). BUT aura:id is undefined because it can't be dynamically assigned with a merge field. Here's how I was trying to assign aura:id in the iteration markup, but that aura:id assignment doesn't work.
<aura:component >
    <aura:attribute name="topic" type="Topic__c"/>
        <div class="slds-tile slds-hint-parent">
            <div class="slds-form-element slds-is-required">
                <div class="slds-form-element__control">
                    <ui:inputNumber aura:id="{!v.topic.Id}" label="{!v.topic.Name}"
                                    class="slds-input"
                                    labelClass="slds-form-element__label"
                                    value = "{!v.topicResult.score__c}" />   
                </div>
            </div> 
        </div>
</aura:component>
I've double checked that {v.topic.Id} is valid (I can assign it to the label with no problem). I've tried using a simple string in a variable, also with no success. It appears aura:id has to be hard-coded.

So, any ideas on another attribute I can use to identify and call each field?
Is there a way to do a component.find() on a different attribute, like label, that can be set dynamically?

I'm using ui:inputNumber based on my use of it in the Lightning Component Trail on Trailhead (the one with Expenses and the Camping List), but I'm seeing an altenative --  lightning:input (Beta). I'm reading the docs on it, thinking maybe I can use the name attribute, but not sure if I can then component.find() it by name.

Any insight or ideas out there? Thanks.
Hi,
I am calling a method saveData from my js controller when all the fields of my form are filled :
$("#myForm").validate({
            rules: {
                title: {required: true},
                firstname: {required: true},
                lastname: {required: true},
            },
            messages: {
                title:  "Please type and select a title",
                firstname: "Please enter the client first name",
                lastname: "Please enter the clients last name",
            },   
            tooltip_options:{
                '_all_': {placement: 'top'},
            },
            focusInvalid: false,
            submitHandler: function() {
                if($('#confirmation').prop("checked") == false ){
                    helper.showErrorMessage();
                }else {
                    helper.saveData(component);
                }
            }
        });
    },

The callback of this method is never called - and when I open the developer tools , the callback function is called and working fine
saveData: function(component){
        var action = component.get("c.saveClient");
        actionJInsured.setParams({
            "firstname": firstname,
            "lastname": lastname,
            "title": "title"
        });
        action .setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                alert('inside the callback');
            }
        });
        $A.enqueueAction(action);
    }

does any one has an explanation of why the code is only working when open the developer tools in the browser please?
Hi,

I am new to Apex and visualforce and having ago!

I have managed to create a small visualforce page to show charts on my projects page which filters fine using the following code (section of): -
<apex:page StandardController="pse__Proj__c">
   <apex:pageblock >
        <apex:pageblockSection columns="4">
               <analytics:reportChart reportId="00OJ0000000hi2k" 
                    filter="{column:'pse__Proj__c.Name', operator:'equals', value:'{!pse__Proj__c.Name}'}" size="small">
        </analytics:reportChart>

When I click on this it opens the report within the small visualforce section and I would like this chart, when clicked to open in a new window, or even in a new tab.

Do I need a controller for this or is it simple code like open.window...parent etc ...
Thanks

Me
  • February 05, 2016
  • Like
  • 1
Hi,

In our one of appexchange app, we have exposed REST webservice. Here, user just passes the SOQL string to our expose REST API and in the form of response we are returning records.
As this is a part of appexchange, so its mandatory to do FLS checking, but as per our application scope SOQL string is generating outside Salesforce and user just passes SOQL string to my Salesforce Webservice, so I am wondering how we can do FLS checking for dynamic SOQL string.

Thanks,
Rupali

We are creating the task as a centralized user.
We are using the SOAP api via the PHP library. We are using an enterprise WSDL and client

Here an example of the API call we make to create the task:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns1="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><ns1:SessionHeader><ns1:sessionId>00D8E0000008eZd!AQcAQBNHquRZygS9Mie4p2dHvRIWArlv2.AG8nHufSxtHRYsMRlsQl3iq5NZJz6yeJtkR6qPRs7rH_72NKGjhgzJWjOQoA_s</ns1:sessionId></ns1:SessionHeader><ns1:EmailHeader><ns1:triggerAutoResponseEmail>true</ns1:triggerAutoResponseEmail><ns1:triggerOtherEmail>true</ns1:triggerOtherEmail><ns1:triggerUserEmail>true</ns1:triggerUserEmail></ns1:EmailHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:create><ns1:sObjects xsi:type="ns1:Task"><Id/><OwnerId>005D00000069MdXIAU</OwnerId><Priority>Normal (default)</Priority><Subject>test task assignment</Subject><Type>Other</Type><WhoId>00Q8E000001Gu2XUAS</WhoId></ns1:sObjects></ns1:create></SOAP-ENV:Body></SOAP-ENV:Envelope>
POST /services/Soap/c/35.0/00D8E0000008eZd/0DF8E000000003j HTTP/1.1 Host: cs87.salesforce.com Connection: Keep-Alive User-Agent: salesforce-toolkit-php/27.0 Accept-Encoding: gzip, deflate Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 926
I have a visualforce page with this code:
<apex:page contentType="application/javascript">
<![CDATA[
for (var i=0; i < 5; i++) {
  console.log('Hello World');
}
]]>
</apex:page>

When I load the page up I get this:
<![CDATA[ for (var i=0; i < 5; i++) {]]><![CDATA[   console.log('Hello World');]]><![CDATA[ }]]><![CDATA[ ]]>

This is obviously incorrect and a bug. The content type is application/javascript and the output is outputting XML. The output should be the CDATA contents.