• Raja Jammula
  • NEWBIE
  • 65 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 29
    Replies
/a2j/e?
retURL={!Opportunity.Id}&
ent=Opportunity&
CF00N5000000AJ7BR={!Opportunity.Account}&
CF00N5000000AJ7BR_lkid={!Opportunity.AccountId}&
CF00N50000003bRst={!Opportunity.Name}&
CF00N50000003bRst_lkid={!Opportunity.Id}&
CF00N500000030Lze_lkid={!$User.Id}&
CF00N500000030Lze={!$User.FirstName}+{!$User.LastName}&
00N5000000AJ7C2={!Account.EIN__c}&

CF00N500000030Lze is a custom owner field(look up to employee) in the custom object when i am trying to insert a record it's throwing me an error: 
Error: Owner: id value of incorrect type: 00550000005hHsg
Hi all, i am getting this error in my Test class:

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

Don't know how to solve this? Any help would be rally helpful

Scenario: updating the opp owner based on the product owner from account

@isTest
    public static void testhandleCorporateSalesBeforeInsert() {
        
        Id rTDCXX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CDC').getRecordTypeId();
        Id rTPCTX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CSP').getRecordTypeId();
           Test.startTest();
        List<Custom_Setopp__c> oppownerList = new List<Custom_Setopp__c>();
        Custom_Setopp__c Products1 = new Custom_Setopp__c(Name = 'DC', Record_Type__c = 'CDC', 
                                                                PTC__c = 'DC');
        oppownerList.add(Products1);
        Custom_Setopp__c Products2 = new Custom_Setopp__c(Name = 'Paty', Record_Type__c = 'CSP', 
                                                                PTC__c = 'PAY');
        oppownerList.add(Products2);
        insert oppownerList;
        
        Profile p = [select id from profile where name='Standard User'];
        RecordType rt = [select id from recordtype where sobjecttype = 'Opportunity' and name = 'CDC'];
        User u = new User(alias = 'standt', email='testuser@test.com',
                          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                          localesidkey='en_US', profileid = p.Id, employeenumber = 'A000000',
                          timezonesidkey='America/Los_Angeles', username='testuser737712@test.com', IsActive = true);
        insert u;          
        
        System.runAs (u) {
            UserRole r = new UserRole(Name='ACCROL');      
            insert r;
        
        Account account = new Account(Name='Test Account',Type='PS',CSG_Account_stat__c='PROSPECT',OwnerId=u.Id,BillingStreet='123 Main',BillingCity='Co',BillingState = 'CA',BillingPostalCode='67890',Phone='123-456-7890');
        insert account;
        system.debug('in test account id ::'+account.Id);
            
        List<Employee__c> empList = new List<Employee__c>();
        Employee__c Employee1 = new Employee__c(Name='Testing1', Employee_Number__c='A000000', Email__c='testuser@test.com', User__c = u.Id);
        empList.add(Employee1);
        insert empList;
        system.debug('empList::'+empList);
            
        List<Prod__c> prodList = new List<Prod__c>();
        Prod__c product1 = new Prod__c(Name='DC - Test Account',PC__c = 'DC',Account__c = account.Id, 
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id, AE__c = Employee1.Id);
        prodList.add(product1);
        Prod__c product2 = new Prod__c(Name='PAY - Test Account',PC__c = 'PAY',Account__c = account.Id,
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id);
        prodList.add(product2); 
        insert prodList;
        
        system.debug('in test prodList id ::'+prodList);
        
        List<Opportunity> oppList = new List<Opportunity>();
        Opportunity opp1 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion', 
                                          Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%',
                                           CloseDate = System.today(), RecordTypeId = rTDCX);
        oppList.add(opp1);
        Opportunity opp2 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion',
                                           Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%', 
                                           CloseDate = System.today(), RecordTypeId = rTPCTX);
        oppList.add(opp2);
        insert oppList;
        system.debug('oppList[0].OwnerId ::'+oppList[0].OwnerId);
        //System.assertEquals(Userinfo.getUserId(), oppList[0].OwnerId);
        
        Test.stopTest();
    }
  }

Actual Class:

public void HSCBI(Opportunity[] opportunities) {
        // Find all CDC opportunities
        Set<Id> accountIds = new Set<Id>();
        List<Opportunity> csopp = new List<Opportunity>();
        Map<String,String> prt = new Map<String,String>();
        Map<String,String> rtwp = new Map<String,String>();
        
        for(Custom_Setopp__c csRec : Custom_Setopp__c.getall().values() ){
            prt.put(csRec.Record_Type__c,csRec.Product_Type__c);
            rtwp.put(csRec.Product_Type__c,csRec.Record_Type__c);
        }
        
        for (Opportunity opportunity : opportunities) {
            Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
            if (rt != null && prt.containsKey(rt.getName()) ){ 
                accountIds.add(opportunity.AccountId);
                csopp.add(opportunity);
            }
        }
        
        // If no CS opportunities found then discontinue processing
        if (csopp.isEmpty())
            return;
        
        Map<Id,Map<String,Id>> acpto = new Map<Id,Map<String,Id>>();
        system.debug('accountIds::'+accountIds+'\nprt.values()::'+prt.values());
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c ];
         system.debug('pl::'+pl);
        for (Prod__c prod : [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c 
                                      WHERE Account__c in : accountIds AND PC__c in :prt.values() AND Owner__r.User__c != null]){
                       
             Map<String,Id> Pom = new Map<String,Id>();
             
             if(acpto.containsKey(prod.Account__c)){
                Pom = acpto.get(prod.Account__c);
             }
             Pom.put(rtwp.get(prod.PC__c),prod.Owner__r.User__c);
             acpto.put(prod.Account__c,Pom);
             system.debug('owner::'+acpto.values()+'\nPom.values()::'+Pom.values());
           }
         
        // For new CS* opportunities, auto transfer owner to product owner 
        for (Opportunity opportunity : csopp) { 
            if (opportunity.StageName != null) {
                Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
                                
                if(acpto.containsKey(opportunity.AccountId) && 
                    acpto.get(opportunity.AccountId).containsKey(rt.getName()) ){
                    opportunity.OwnerId = acpto.get(opportunity.AccountId).get(rt.getName()) ;
                }
            }
        } 
    }
Hi all, i am getting this error in my Test class:

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

Don't know how to solve this? Any help would be rally helpful

Scenario: updating the opp owner based on the product owner from account

@isTest
    public static void testhandleCorporateSalesBeforeInsert() {
        
        Id rTDCXX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CDC').getRecordTypeId();
        Id rTPCTX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CSP').getRecordTypeId();
           Test.startTest();
        List<Custom_Setopp__c> oppownerList = new List<Custom_Setopp__c>();
        Custom_Setopp__c Products1 = new Custom_Setopp__c(Name = 'DC', Record_Type__c = 'CDC', 
                                                                PTC__c = 'DC');
        oppownerList.add(Products1);
        Custom_Setopp__c Products2 = new Custom_Setopp__c(Name = 'Paty', Record_Type__c = 'CSP', 
                                                                PTC__c = 'PAY');
        oppownerList.add(Products2);
        insert oppownerList;
        
        Profile p = [select id from profile where name='Standard User'];
        RecordType rt = [select id from recordtype where sobjecttype = 'Opportunity' and name = 'CDC'];
        User u = new User(alias = 'standt', email='testuser@test.com',
                          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                          localesidkey='en_US', profileid = p.Id, employeenumber = 'A000000',
                          timezonesidkey='America/Los_Angeles', username='testuser737712@test.com', IsActive = true);
        insert u;          
        
        System.runAs (u) {
            UserRole r = new UserRole(Name='ACCROL');      
            insert r;
        
        Account account = new Account(Name='Test Account',Type='PS',CSG_Account_stat__c='PROSPECT',OwnerId=u.Id,BillingStreet='123 Main',BillingCity='Co',BillingState = 'CA',BillingPostalCode='67890',Phone='123-456-7890');
        insert account;
        system.debug('in test account id ::'+account.Id);
            
        List<Employee__c> empList = new List<Employee__c>();
        Employee__c Employee1 = new Employee__c(Name='Testing1', Employee_Number__c='A000000', Email__c='testuser@test.com', User__c = u.Id);
        empList.add(Employee1);
        insert empList;
        system.debug('empList::'+empList);
            
        FESCoProductTriggerHandler.setFirstRun();    
        List<Prod__c> prodList = new List<Prod__c>();
        Prod__c product1 = new Prod__c(Name='DC - Test Account',PC__c = 'DC',Account__c = account.Id, 
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id, AE__c = Employee1.Id);
        prodList.add(product1);
        Prod__c product2 = new Prod__c(Name='PAY - Test Account',PC__c = 'PAY',Account__c = account.Id,
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id);
        prodList.add(product2); 
        insert prodList;
        
        system.debug('in test prodList id ::'+prodList);
        
        List<Opportunity> oppList = new List<Opportunity>();
        Opportunity opp1 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion', 
                                          Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%',
                                           CloseDate = System.today(), RecordTypeId = rTDCX);
        oppList.add(opp1);
        Opportunity opp2 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion',
                                           Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%', 
                                           CloseDate = System.today(), RecordTypeId = rTPCTX);
        oppList.add(opp2);
        insert oppList;
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c WHERE PC__c = 'DC' AND Account__c = :account.Id];
         system.debug('pl2::'+pl);
        //System.assertEquals(Userinfo.getUserId(), oppList[0].OwnerId);
        
        Test.stopTest();
    }
  }

Actual Class:

private void HSCBI(Opportunity[] opportunities) {
        // Find all CDC opportunities
        Set<Id> accountIds = new Set<Id>();
        List<Opportunity> csopp = new List<Opportunity>();
        Map<String,String> prt = new Map<String,String>();
        Map<String,String> rtwp = new Map<String,String>();
        
        for(Custom_Setopp__c csRec : Custom_Setopp__c.getall().values() ){
            prt.put(csRec.Record_Type__c,csRec.Product_Type__c);
            rtwp.put(csRec.Product_Type__c,csRec.Record_Type__c);
        }
        
        for (Opportunity opportunity : opportunities) {
            Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
            if (rt != null && prt.containsKey(rt.getName()) ){ 
                accountIds.add(opportunity.AccountId);
                csopp.add(opportunity);
            }
        }
        
        // If no CS opportunities found then discontinue processing
        if (csopp.isEmpty())
            return;
        
        Map<Id,Map<String,Id>> acpto = new Map<Id,Map<String,Id>>();
        system.debug('accountIds::'+accountIds+'\nprt.values()::'+prt.values());
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c ];
         system.debug('pl::'+pl);
        for (Prod__c prod : [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c 
                                      WHERE Account__c in : accountIds AND PC__c in :prt.values() AND Owner__r.User__c != null]){
                       
             Map<String,Id> Pom = new Map<String,Id>();
             
             if(acpto.containsKey(prod.Account__c)){
                Pom = acpto.get(prod.Account__c);
             }
             Pom.put(rtwp.get(prod.PC__c),prod.Owner__r.User__c);
             acpto.put(prod.Account__c,Pom);
             system.debug('owner::'+acpto.values()+'\nPom.values()::'+Pom.values());
           }
         
        // For new CS* opportunities, auto transfer owner to product owner 
        for (Opportunity opportunity : csopp) { 
            if (opportunity.StageName != null) {
                Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
                                
                if(acpto.containsKey(opportunity.AccountId) && 
                    acpto.get(opportunity.AccountId).containsKey(rt.getName()) ){
                    opportunity.OwnerId = acpto.get(opportunity.AccountId).get(rt.getName()) ;
                }
            }
        } 
    }
Message: Uncaught Error in $A.getCallback() [Invalid date value]
Callback failed: apex://sortablegrid.sdgController/ACTION$GetSDGInitialLoad

In the sortable data grid i created there is no date field 

component descriptor:
markup://sortablegrid:sdg

File Name:
auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js

Function:
Action.$finishAction$

Skip trace:

Action.$finishAction$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:13728:22
QueuedActionsMetricsPlugin.$actionFinishOverride$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:27804:24
Object.Aura.$Utils$.$Override$.$continuation$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:7021:20
Action.bound [as $finishAction$]()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:6958:29
AuraClientService.$singleAction$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:15570:14
AuraClientService.$processResponses$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:17134:14
QueuedActionsMetricsPlugin.$actionsProcessResponses$()@https:/auraFW/javascript/9cP17KDqrLzgsg8CdQTfjw/aura_proddebug.js:27823:23

The sortable data grid i created doesn't have a date field at all
I am using below script:
<script>
        function setLogcallURL(){
        var url='/00T/e?title=Call&who_id={!Contact.Id}&retURL=/{!Contact.Id}' 
        
        if("{!$Profile.Name}" == "WI" && ("{!$UserRole.Name}"=="AE - E"||"{!$UserRole.Name}"=="AE - W"||"{!$UserRole.Name}"=="AE - S")){ 
            url+='&tsk5=Meeting'; 
            url+='&tsk4={!TODAY()}'; 
            url+='&tsk12=Completed'; 
            url+='&RecordType=0120j0000008dlO'; 
            url+='&ent=Task'; 
        }else if("{!$Profile.Name}" == "WI") { 
            url+='&tsk5=Call'; 
            url+='&followup=1'; 
            url+='&tsk4={!TODAY()}'; 
            url+='&RecordType=01250000000HiDD'; 
            url+='&RecordType_fu=01250000000HiDD'; 
        }else{ 
            url+='&followup=1'; 
            url+='&tsk5=Call'; 
        }
        window.open(url,"_self");
        }
    
    </script>
from vf page:
     <apex:commandButton value="Log a Call"  oncomplete="setLogcallURL()" rendered="{!contact.CSG_Status__c == 'Active'}"/>

&tsk4={!TODAY()} it's not the populating the date correctly 
it's populating as: Tue Sep 26 00:00:00 GMT 2017 instead 09/26/2017

​can anyone let me know what i have to change here to populate the date as 09/26/2017
Hi, i am getting this error:
URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com. 

this is the javascript button i am using:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var url='/00T/e?title=Call&who_id={!Contact.Id}&&retURL=/{!Contact.Id}' 

if("{!$Profile.Name}" == "WICS" && ("{!$UserRole.Name}"=="AE - E"||"{!$UserRole.Name}"=="AE - W"||"{!$UserRole.Name}"=="AE - S")){ 
url+='&tsk5=Meeting'; 
url+='&tsk4={!TODAY()}'; 
url+='&tsk12=Completed'; 
url+='&RecordType=0120j0000008dlO'; 
url+='&ent=Task'; 
}else if("{!$Profile.Name}" == "WI Corporate Sales") { 
url+='&tsk5=Call'; 
url+='&followup=1'; 
url+='&tsk4={!TODAY()}'; 
url+='&RecordType=01250000000HiDD'; 
url+='&RecordType_fu=01250000000HiDD'; 
}else{ 
url+='&followup=1'; 
url+='&tsk5=Call'; 
}  
window.open(url,'_blank');

i am not getting where i am going wrong here can anyone help
Javascript: I am getting Unexpected token error for below code can you please help:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var obj;
var task5;
var recordtypeid;
var followup;
var recordtypefol;
if("{!$Profile.Name}" == "TX1" || 
"{!$Profile.Name}"== "TX2"||
"{!$Profile.Name}"== "WX1"||
"{!$Profile.Name}"== "WX2"||
"{!$Profile.Name}"== "WX3"||
"{!$Profile.Name}"== "WX4"|| 
"{!$Profile.Name}" == "CC"){

obj='a1r';
}
else{
obj='00T';
}
alert(obj);

var url='/'+obj+'/e?CF00N50000002CzJi={!Account.Name}&CF00N50000002CzJi_lkid={!Account.Id}&retURL=/{!Contact.Id}&title=Call&who_id={!Contact.Id}&00N50000002D0zP={!User.Primary_Product__c}'
if(obj=="a1r")
{
url+='&followup=1&tsk5=call'
}

if(obj=="00T"){
if("{!$Profile.Name}" == "WI" && ("{!$UserRole.Name}"=="AS - E"||"{!$UserRole.Name}"=="AS - M"||"{!$UserRole.Name}"=="AS - T")){
task5="Meeting";
recordtypeid="0123B0000008tqK";
followup='';
recordtypefol="0123B0000008tqK";
}elseif("{!$Profile.Name}" == "WI Corporate Sales") {
task5="call";
recordtypeid="01250000000HiDD";
followup ="1";
recordtypefol="01250000000HiDD"; 
}else{
url+='&tsk5='+task5+'$tsk12=Completed'+'&RecordType='+recordtypeid+'&RecordType_fu='+recordtypefol+'&followup='+followup+'&tsk4={!TODAY()}'
}
}
else{
url+='&followup=1&tsk5=call'
}

window.parent.open(url, "_self");
I am New to apex development:

this is my trigger:

trigger ContactTrigger on Contact(after delete, after insert, after undelete, after update, before delete, before insert, before update) {

  ContactTriggerHandler handler = new ContactTriggerHandler();

  /* Before Insert */
  if(Trigger.isInsert && Trigger.isBefore){
   // handler.OnBeforeInsert(Trigger.new);
  }
  
  /* After Insert */
  else if(Trigger.isInsert && Trigger.isAfter){
    handler.OnAfterInsert(Trigger.new);
  }
  
  /* Before Update */
  else if(Trigger.isUpdate && Trigger.isBefore){
    //handler.OnBeforeUpdate(Trigger.old, Trigger.new, Trigger.newMap, Trigger.oldMap);
  }
  
  /* After Update */
  else if(Trigger.isUpdate && Trigger.isAfter){
   // handler.OnAfterUpdate(Trigger.old, Trigger.new, Trigger.newMap, Trigger.oldMap);
  }
  
  /* Before Delete */
  else if(Trigger.isDelete && Trigger.isBefore){
    //handler.OnBeforeDelete(Trigger.old, Trigger.oldMap);
  }
  
  /* After Delete */
  else if(Trigger.isDelete && Trigger.isAfter){
    handler.OnAfterDelete(Trigger.old, Trigger.oldMap);
  }

  /* After Undelete */
  else if(Trigger.isUnDelete){
    //handler.OnUndelete(Trigger.new);
  }

}

this is my class:

public without sharing class ContactTriggerHandler { 
   
    public void OnBeforeInsert(Contact[] newContacts) {
        // BEFORE INSERT LOGIC
    
    }
    
    public void OnAfterInsert(Contact[] newContacts) {
        // AFTER INSERT LOGIC
         insertcontact(newContacts, new Map<Id,Contact>());
    }
    
    public void OnBeforeUpdate(Contact[] oldContacts, Contact[] updatedContacts, Map<ID, Contact> newMap, Map<ID, Contact> oldMap) {
        // BEFORE UPDATE LOGIC
             
    }
    
    public void OnAfterUpdate(Contact[] oldContacts, Contact[] updatedContacts, Map<Id, Contact> newMap, Map<Id, Contact> oldMap) {
        // AFTER UPDATE LOGIC
        
    }
    
    public void OnBeforeDelete(Contact[] contactsToDelete, Map<ID, Contact> oldMap) {
        // BEFORE DELETE LOGIC
           //Deletecontact(contactsToDelete);
    }
    
    public void OnAfterDelete(Contact[] deletedContacts, Map<ID, Contact> oldMap) {
        // AFTER DELETE LOGIC
        //Deletecontact(deletedContacts);
        insertcontact(deletedContacts, oldMap);
    }
    
    public void OnUndelete(Contact[] restoredContacts) {
        // AFTER UNDELETE LOGIC
        
    }
    
    public void insertcontact(Contact[] Contacts, Map<ID,Contact> oldMap ){
        // List<Contact> contactList = [SELECT ID, account.Contact_Count__c FROM Contact];
        set<Id> accid = new set<Id>();
        //List<Contact> contactList = new List<Contact>();
        for(contact con: Contacts){
            accid.add(con.accountid);
        }
        
       for(contact cons: oldMap.values()){
            accid.add(cons.accountId);
        }
        
           List <Account> accList = new List <Account>();
        
        //if(newMap.get(con.Id)!=oldMap.get(con.Id)
        /* Aggregate Query */
        for(Account acc:[SELECT Id,Name,Contact_Count__c,(Select Id from Contacts) from Account where Id IN: accid]){
            if(acc!=null){
            Account accObj = new Account ();
            accObj.Id = acc.Id;
            accObj.Contact_Count__c = acc.Contacts.size();
            system.debug('accsize:--->' +acc.Contacts.size() );
            accList.add(accObj);
        }
            else{
             Account ccObj = new Account ();
                ccObj.Id = acc.Id;
             ccObj.Contact_Count__c = 0;
             accList.add(ccObj);
            }
        }
        update accList;
    }
    
     public static void Deletecontact(Contact[] deletedContacts){
         
         set<Id> accid = new set<Id>();
         for(contact con: deletedContacts){
             accid.add(con.accountId);
         }
         
         List <Account> accList = new List <Account>();
         
         //if(newMap.get(con.Id)!=oldMap.get(con.Id)
         // Aggregate Query
         for(Account acc:[SELECT Id,Name,Contact_Count__c,(Select Id from Contacts) from Account where Id IN: accid]){
             system.debug('acclist:--->' +acc );
             Account accObj = new Account ();
             accObj.Id = acc.Id;
             system.debug('accsize:--->' +acc.Contacts.size() );
             accObj.Contact_Count__c = acc.Contacts.size();
             system.debug('accsize:--->' +acc.Contacts.size() );
             accList.add(accObj);
         }
            system.debug('accList:--->' +accList);
         update accList;
     }
}

when i try to insert contact the field is getting updated but when i delete it it's not getting updated.
can anyone help me where i am going wrong.

 
Hi all can you please help me on this:
I am getting the above error 
List<req> reqlist = new List<req>();        
        set<Id> accountIds = new set<Id>();        
        
        for (opp op : opps) {
              accountIds.add(op.AccountId);
        }
        
        List<req> ExReq = new List<req>([Select Id, Type__c, Account__c, opp__c,stat__c,Opp__r.Is_Upd__c FROM req Where Account__c =:accountIds                                  
                                    AND Opportunity__c IN:opps AND Type__c = 'XYZ']);
        
        List<req> reqcan = new List<req>
        Integer reqIndex = 0;
        
        for(req req : ExReq){
            if(req.Opp__r.Is_Upd__c == true){
                req.stat__c = 'Cancelled';
                reqcan.add(req);
                ExReq.remove(reqIndex);
            }
            reqIndex = reqIndex + 1 ;
        }
        
        if(!reqcan.isEmpty()){
            update reqcan ;
        }
Hi 

i have a below code i am getting the error:
System.NullPointerException: Attempt to de-reference a null object at line 66

global class Match implements Database.Batchable<sObject>{
    
   global Database.QueryLocator start(Database.BatchableContext BC){
       
       String query = 'SELECT Name, Id, test__c, opportunity__c, test1__c FROM pro__c ';
       
       return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<pro__c> planProjects){
        Map<String,List<task__c>> taskw = new Map<String,List<task__c>>();
        Map<String,List<milest>> milestW = new Map<String,List<milest>>();
        
           List<String> ppIds = new List<String>();
        for(pro__c pp : planProjects){
            ppIds.add(pp.Id);
        }
       
        List<task__c> Tractas = [SELECT Id,Name,Tracker__r.TrP__r.pro__c,Status__c,
                                                        Comments__c,Completed_Date__c
                                                        FROM  task__c
                                                        WHERE Tracker__r.TrP__r.pro__c in :ppIds];
        
        for(task__c tt : Tractas){
            List<task__c> taskl = new List<task__c>();
            if(taskw.containsKey(tt.Tracker__r.TrP__r.pro__c)){
                
                taskl = taskw.get(tt.Tracker__r.TrP__r.pro__c);    
            }
            taskl.add(tt);
            taskw.put(tt.Tracker__r.TrP__r.pro__c,taskl);
        }
        
        List<milest> milest= [SELECT Id,Name,Status__c,Comments__c,Date__c,pro__c 
                                                    FROM milest
                                                    WHERE pro__c in :ppIds];
                                                    
        for(milest milestone : milest){
            
            List<milest> mileList = new List<milest>();
            
            if(milestW.containsKey(milestone.pro__c)){
                
                mileList = milestW.get(milestone.pro__c);
                
            }
            
            mileList.add(milestone);
            milestW.put(milestone.pro__c,mileList);
            
        }
       
        List<task__c> tasksToUpdate = new List<task__c>();
        LIst<MilestoneMapping__c> mappingRecords = MilestoneMapping__c.getall().values();
        Map<String,String> milestoneMap = new Map<String,String>();
        
        for(MilestoneMapping__c mappingRec : mappingRecords){
            milestoneMap.put(mappingRec.Task_Name__c, mappingRec.Milestone_Name__c);
        }
       
        for(String ppId : taskw.keyset()){
            
            for(task__c tt : taskw.get(ppId)){
                String milestoneMappinName = milestoneMap.get(tt.Name);
                
                
           ---->     for(milest mile :milestW.get(ppId) ){
                    
                    if(mile.Name == milestoneMappinName){
                        tt.Status__c = mile.Status__c;
                        tt.Comments__c = mile.Comments__c;
                        tt.Completed_Date__c = mile.Date__c;
                        tasksToUpdate.add(tt);
                    }
                }

            }
        }    
       
        if(!tasksToUpdate.isEmpty()){
           update tasksToUpdate;
        }
    }

can anyone please help me to get rid of this error
Hi, i have a scenario where i have a button where i am doing URL hacking and populating the values from one object to another object on click of  a button.

The problem here is the button is called from two places. There is a field 'Product_Type__c ' which is a single picklist field and populates the value to the field-'product' on the destination. but on second place where we are calling the button the field is multi-select picklist field - 'Product_Categories__c ' and the destination field is same field - 'product'. when i am calling this it won't take the value from both the places.

so i thought of creating a formula field to populate the values and then use this formula field in URL hack of the button. but i am getting an error when trying to do it. the formula i am using:

IF( ISPICKVAL(Type, 'Multi-Product')  , TEXT(Product_Categories__c ) ,  Product_Type__c )

as multiselect can't use text 

 can anyone help me
Hi i am working on lead conversion.I need to override the standard 'Convert' button given by salesforce with VisualForce page and write apex code for it. I need help in the following
1. There are many fields(Standard/Custom) in lead that need to be mapped to Account,Contact and Opportunity custom fields. 
2. I have a multi select picklist field 'product' on Lead screen which has values x,y,z
If two products (or three) is selected on Lead Screen then 2 Opportunity records should be created one with product as 'X' and another as 'Y'.
 
Please help me achieve this functionality.Thanks in Advance.
used number and currency field in different screens in flow and assigned the number and currency field to a variable but in record create i am not able to use that variable
Hi All 
When the plan project is created from the opportunity, the flow checks for the XYZ fields on the Primary Quote and updates the values on the Plan record that is XYZ fields

I have wriite code like below:

public void populateIndicatorsData(Map<String,String> planWithOpp){
    Map<String,String> planWithOpp = new Map<String,String>();
        List<BigMachines__Quote__c> quotes = [SELECT id,Participant_Distribution_Advice__c,Participant_Investment_Advice__c,
                                                      BigMachines__Opportunity__C 
                                                      FROM BigMachines__Quote__c 
                                                      WHERE BigMachines__Is_Primary__c = true AND BigMachines__Opportunity__c in :planWithOpp.values()]; 
        if(!quotes.isEmpty()){
            Map<String,BigMachines__Quote__c> oppWithQuote = new Map<String,BigMachines__Quote__c>();
            for(BigMachines__Quote__c q : quotes){
                oppWithQuote.put(q.BigMachines__Opportunity__c ,q);
            }
            List<Auto_Bundle__c> PlanListToUpdate = new List<Auto_Bundle__c>();
            for(String planId : planWithOpp.keySet()){
                Auto_Bundle__c plan = new Auto_Bundle__c(id = planId);
                if(oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c != null && oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c.toLowercase() != 'null')
                {   
                    plan.Participant_Distribution_Advice__c =  oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c;
                    
                }
                if(oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c != null && oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c.toLowercase() != 'null')
                {   
                    plan.Participant_Investment_Advice__c = oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c ;
                    
                }
                if(plan.Participant_Distribution_Advice__c != null || oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c != null)
                    PlanListToUpdate.add(plan);
            }
            if(!PlanListToUpdate.isEmpty()){
                update PlanListToUpdate ;
            }
        }
    }

but there is validation rule in the plan object where XYZ (Picklist) field values should match exactly 
But in the quote the picklist values slighlty differs EX: in quote - Find Error (FE), in plan - Find Error
Now, i need to modify my code little bit like: First convert the values in quote to match to the valus in plan and then update the plan

can anyone help me on this on how to write this?
Hi I have a flow where i created a collection variable and assigned values to it by running loop and i want to use that collection variable basically the ID of that variable in a dynamic record choice screen 


i don't know i explained it clearly but can you suggest me any solution 
display a line inUser-added image the UI?
iam working on a flow and i need to include this how can i acheive it?
Hi i have a flow where i am searching for a name and i am selecting the name but i have more than 200 records to show but in visual flow there is a hard limit of 200. is there any workaround to show the next 200 records  
Hi all, i am getting this error in my Test class:

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

Don't know how to solve this? Any help would be rally helpful

Scenario: updating the opp owner based on the product owner from account

@isTest
    public static void testhandleCorporateSalesBeforeInsert() {
        
        Id rTDCXX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CDC').getRecordTypeId();
        Id rTPCTX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CSP').getRecordTypeId();
           Test.startTest();
        List<Custom_Setopp__c> oppownerList = new List<Custom_Setopp__c>();
        Custom_Setopp__c Products1 = new Custom_Setopp__c(Name = 'DC', Record_Type__c = 'CDC', 
                                                                PTC__c = 'DC');
        oppownerList.add(Products1);
        Custom_Setopp__c Products2 = new Custom_Setopp__c(Name = 'Paty', Record_Type__c = 'CSP', 
                                                                PTC__c = 'PAY');
        oppownerList.add(Products2);
        insert oppownerList;
        
        Profile p = [select id from profile where name='Standard User'];
        RecordType rt = [select id from recordtype where sobjecttype = 'Opportunity' and name = 'CDC'];
        User u = new User(alias = 'standt', email='testuser@test.com',
                          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                          localesidkey='en_US', profileid = p.Id, employeenumber = 'A000000',
                          timezonesidkey='America/Los_Angeles', username='testuser737712@test.com', IsActive = true);
        insert u;          
        
        System.runAs (u) {
            UserRole r = new UserRole(Name='ACCROL');      
            insert r;
        
        Account account = new Account(Name='Test Account',Type='PS',CSG_Account_stat__c='PROSPECT',OwnerId=u.Id,BillingStreet='123 Main',BillingCity='Co',BillingState = 'CA',BillingPostalCode='67890',Phone='123-456-7890');
        insert account;
        system.debug('in test account id ::'+account.Id);
            
        List<Employee__c> empList = new List<Employee__c>();
        Employee__c Employee1 = new Employee__c(Name='Testing1', Employee_Number__c='A000000', Email__c='testuser@test.com', User__c = u.Id);
        empList.add(Employee1);
        insert empList;
        system.debug('empList::'+empList);
            
        List<Prod__c> prodList = new List<Prod__c>();
        Prod__c product1 = new Prod__c(Name='DC - Test Account',PC__c = 'DC',Account__c = account.Id, 
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id, AE__c = Employee1.Id);
        prodList.add(product1);
        Prod__c product2 = new Prod__c(Name='PAY - Test Account',PC__c = 'PAY',Account__c = account.Id,
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id);
        prodList.add(product2); 
        insert prodList;
        
        system.debug('in test prodList id ::'+prodList);
        
        List<Opportunity> oppList = new List<Opportunity>();
        Opportunity opp1 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion', 
                                          Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%',
                                           CloseDate = System.today(), RecordTypeId = rTDCX);
        oppList.add(opp1);
        Opportunity opp2 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion',
                                           Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%', 
                                           CloseDate = System.today(), RecordTypeId = rTPCTX);
        oppList.add(opp2);
        insert oppList;
        system.debug('oppList[0].OwnerId ::'+oppList[0].OwnerId);
        //System.assertEquals(Userinfo.getUserId(), oppList[0].OwnerId);
        
        Test.stopTest();
    }
  }

Actual Class:

public void HSCBI(Opportunity[] opportunities) {
        // Find all CDC opportunities
        Set<Id> accountIds = new Set<Id>();
        List<Opportunity> csopp = new List<Opportunity>();
        Map<String,String> prt = new Map<String,String>();
        Map<String,String> rtwp = new Map<String,String>();
        
        for(Custom_Setopp__c csRec : Custom_Setopp__c.getall().values() ){
            prt.put(csRec.Record_Type__c,csRec.Product_Type__c);
            rtwp.put(csRec.Product_Type__c,csRec.Record_Type__c);
        }
        
        for (Opportunity opportunity : opportunities) {
            Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
            if (rt != null && prt.containsKey(rt.getName()) ){ 
                accountIds.add(opportunity.AccountId);
                csopp.add(opportunity);
            }
        }
        
        // If no CS opportunities found then discontinue processing
        if (csopp.isEmpty())
            return;
        
        Map<Id,Map<String,Id>> acpto = new Map<Id,Map<String,Id>>();
        system.debug('accountIds::'+accountIds+'\nprt.values()::'+prt.values());
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c ];
         system.debug('pl::'+pl);
        for (Prod__c prod : [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c 
                                      WHERE Account__c in : accountIds AND PC__c in :prt.values() AND Owner__r.User__c != null]){
                       
             Map<String,Id> Pom = new Map<String,Id>();
             
             if(acpto.containsKey(prod.Account__c)){
                Pom = acpto.get(prod.Account__c);
             }
             Pom.put(rtwp.get(prod.PC__c),prod.Owner__r.User__c);
             acpto.put(prod.Account__c,Pom);
             system.debug('owner::'+acpto.values()+'\nPom.values()::'+Pom.values());
           }
         
        // For new CS* opportunities, auto transfer owner to product owner 
        for (Opportunity opportunity : csopp) { 
            if (opportunity.StageName != null) {
                Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
                                
                if(acpto.containsKey(opportunity.AccountId) && 
                    acpto.get(opportunity.AccountId).containsKey(rt.getName()) ){
                    opportunity.OwnerId = acpto.get(opportunity.AccountId).get(rt.getName()) ;
                }
            }
        } 
    }
Hi all, i am getting this error in my Test class:

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

Don't know how to solve this? Any help would be rally helpful

Scenario: updating the opp owner based on the product owner from account

@isTest
    public static void testhandleCorporateSalesBeforeInsert() {
        
        Id rTDCXX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CDC').getRecordTypeId();
        Id rTPCTX = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CSP').getRecordTypeId();
           Test.startTest();
        List<Custom_Setopp__c> oppownerList = new List<Custom_Setopp__c>();
        Custom_Setopp__c Products1 = new Custom_Setopp__c(Name = 'DC', Record_Type__c = 'CDC', 
                                                                PTC__c = 'DC');
        oppownerList.add(Products1);
        Custom_Setopp__c Products2 = new Custom_Setopp__c(Name = 'Paty', Record_Type__c = 'CSP', 
                                                                PTC__c = 'PAY');
        oppownerList.add(Products2);
        insert oppownerList;
        
        Profile p = [select id from profile where name='Standard User'];
        RecordType rt = [select id from recordtype where sobjecttype = 'Opportunity' and name = 'CDC'];
        User u = new User(alias = 'standt', email='testuser@test.com',
                          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                          localesidkey='en_US', profileid = p.Id, employeenumber = 'A000000',
                          timezonesidkey='America/Los_Angeles', username='testuser737712@test.com', IsActive = true);
        insert u;          
        
        System.runAs (u) {
            UserRole r = new UserRole(Name='ACCROL');      
            insert r;
        
        Account account = new Account(Name='Test Account',Type='PS',CSG_Account_stat__c='PROSPECT',OwnerId=u.Id,BillingStreet='123 Main',BillingCity='Co',BillingState = 'CA',BillingPostalCode='67890',Phone='123-456-7890');
        insert account;
        system.debug('in test account id ::'+account.Id);
            
        List<Employee__c> empList = new List<Employee__c>();
        Employee__c Employee1 = new Employee__c(Name='Testing1', Employee_Number__c='A000000', Email__c='testuser@test.com', User__c = u.Id);
        empList.add(Employee1);
        insert empList;
        system.debug('empList::'+empList);
            
        FESCoProductTriggerHandler.setFirstRun();    
        List<Prod__c> prodList = new List<Prod__c>();
        Prod__c product1 = new Prod__c(Name='DC - Test Account',PC__c = 'DC',Account__c = account.Id, 
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id, AE__c = Employee1.Id);
        prodList.add(product1);
        Prod__c product2 = new Prod__c(Name='PAY - Test Account',PC__c = 'PAY',Account__c = account.Id,
                                                         stat__c = 'Prospect', Owner__c = Employee1.Id);
        prodList.add(product2); 
        insert prodList;
        
        system.debug('in test prodList id ::'+prodList);
        
        List<Opportunity> oppList = new List<Opportunity>();
        Opportunity opp1 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion', 
                                          Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%',
                                           CloseDate = System.today(), RecordTypeId = rTDCX);
        oppList.add(opp1);
        Opportunity opp2 = new Opportunity(AccountId = account.id, Name = 'Test DC', Type = 'Conversion',
                                           Consultant_Advisor__c = 'Yes', StageName = 'LGC - 0%', 
                                           CloseDate = System.today(), RecordTypeId = rTPCTX);
        oppList.add(opp2);
        insert oppList;
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c WHERE PC__c = 'DC' AND Account__c = :account.Id];
         system.debug('pl2::'+pl);
        //System.assertEquals(Userinfo.getUserId(), oppList[0].OwnerId);
        
        Test.stopTest();
    }
  }

Actual Class:

private void HSCBI(Opportunity[] opportunities) {
        // Find all CDC opportunities
        Set<Id> accountIds = new Set<Id>();
        List<Opportunity> csopp = new List<Opportunity>();
        Map<String,String> prt = new Map<String,String>();
        Map<String,String> rtwp = new Map<String,String>();
        
        for(Custom_Setopp__c csRec : Custom_Setopp__c.getall().values() ){
            prt.put(csRec.Record_Type__c,csRec.Product_Type__c);
            rtwp.put(csRec.Product_Type__c,csRec.Record_Type__c);
        }
        
        for (Opportunity opportunity : opportunities) {
            Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
            if (rt != null && prt.containsKey(rt.getName()) ){ 
                accountIds.add(opportunity.AccountId);
                csopp.add(opportunity);
            }
        }
        
        // If no CS opportunities found then discontinue processing
        if (csopp.isEmpty())
            return;
        
        Map<Id,Map<String,Id>> acpto = new Map<Id,Map<String,Id>>();
        system.debug('accountIds::'+accountIds+'\nprt.values()::'+prt.values());
        List<Prod__c> pl= [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c ];
         system.debug('pl::'+pl);
        for (Prod__c prod : [SELECT Id, PC__c,Owner__c, Account__c,Owner__r.User__c 
                                      FROM Prod__c 
                                      WHERE Account__c in : accountIds AND PC__c in :prt.values() AND Owner__r.User__c != null]){
                       
             Map<String,Id> Pom = new Map<String,Id>();
             
             if(acpto.containsKey(prod.Account__c)){
                Pom = acpto.get(prod.Account__c);
             }
             Pom.put(rtwp.get(prod.PC__c),prod.Owner__r.User__c);
             acpto.put(prod.Account__c,Pom);
             system.debug('owner::'+acpto.values()+'\nPom.values()::'+Pom.values());
           }
         
        // For new CS* opportunities, auto transfer owner to product owner 
        for (Opportunity opportunity : csopp) { 
            if (opportunity.StageName != null) {
                Schema.RecordTypeInfo rt = rtMap.get(opportunity.RecordTypeId);
                                
                if(acpto.containsKey(opportunity.AccountId) && 
                    acpto.get(opportunity.AccountId).containsKey(rt.getName()) ){
                    opportunity.OwnerId = acpto.get(opportunity.AccountId).get(rt.getName()) ;
                }
            }
        } 
    }
Hi, i am getting this error:
URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com. 

this is the javascript button i am using:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var url='/00T/e?title=Call&who_id={!Contact.Id}&&retURL=/{!Contact.Id}' 

if("{!$Profile.Name}" == "WICS" && ("{!$UserRole.Name}"=="AE - E"||"{!$UserRole.Name}"=="AE - W"||"{!$UserRole.Name}"=="AE - S")){ 
url+='&tsk5=Meeting'; 
url+='&tsk4={!TODAY()}'; 
url+='&tsk12=Completed'; 
url+='&RecordType=0120j0000008dlO'; 
url+='&ent=Task'; 
}else if("{!$Profile.Name}" == "WI Corporate Sales") { 
url+='&tsk5=Call'; 
url+='&followup=1'; 
url+='&tsk4={!TODAY()}'; 
url+='&RecordType=01250000000HiDD'; 
url+='&RecordType_fu=01250000000HiDD'; 
}else{ 
url+='&followup=1'; 
url+='&tsk5=Call'; 
}  
window.open(url,'_blank');

i am not getting where i am going wrong here can anyone help
Javascript: I am getting Unexpected token error for below code can you please help:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var obj;
var task5;
var recordtypeid;
var followup;
var recordtypefol;
if("{!$Profile.Name}" == "TX1" || 
"{!$Profile.Name}"== "TX2"||
"{!$Profile.Name}"== "WX1"||
"{!$Profile.Name}"== "WX2"||
"{!$Profile.Name}"== "WX3"||
"{!$Profile.Name}"== "WX4"|| 
"{!$Profile.Name}" == "CC"){

obj='a1r';
}
else{
obj='00T';
}
alert(obj);

var url='/'+obj+'/e?CF00N50000002CzJi={!Account.Name}&CF00N50000002CzJi_lkid={!Account.Id}&retURL=/{!Contact.Id}&title=Call&who_id={!Contact.Id}&00N50000002D0zP={!User.Primary_Product__c}'
if(obj=="a1r")
{
url+='&followup=1&tsk5=call'
}

if(obj=="00T"){
if("{!$Profile.Name}" == "WI" && ("{!$UserRole.Name}"=="AS - E"||"{!$UserRole.Name}"=="AS - M"||"{!$UserRole.Name}"=="AS - T")){
task5="Meeting";
recordtypeid="0123B0000008tqK";
followup='';
recordtypefol="0123B0000008tqK";
}elseif("{!$Profile.Name}" == "WI Corporate Sales") {
task5="call";
recordtypeid="01250000000HiDD";
followup ="1";
recordtypefol="01250000000HiDD"; 
}else{
url+='&tsk5='+task5+'$tsk12=Completed'+'&RecordType='+recordtypeid+'&RecordType_fu='+recordtypefol+'&followup='+followup+'&tsk4={!TODAY()}'
}
}
else{
url+='&followup=1&tsk5=call'
}

window.parent.open(url, "_self");
I am trying to update the Sample_QB_Error__c field with Hello
This code throws "an Invalid or unexpected token"  

Thanks
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")} 
var record = new sforce.SObject("Opportunity"); 
record.Id = ‘{!Opportunity.Id}’; 
record.Sample_QB_Error__c ="Hello"; 
sforce.connection.update([record]); 
window.location.reload();

 
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
if('{!Patient_Insurance__c.Health_Plan_Category__c}'=='Commercial')
{
if('{!Patient_Insurance__c.Health_Plan__c}'==''|| '{!Patient_Insurance__c.Health_Plan_Group_Number__c}'==''||'
{!Patient_Insurance__c.Payor__c}'==''||
'{!Patient_Insurance__c.CoPay_Amount__c}'==''||
'{!Patient_Insurance__c.Coinsurance_Percent__c}'==''||
'{!Patient_Insurance__c.Pharmacy_Benefit_Manager_PCN__c}'==''||
'{!Patient_Insurance__c.Pharmacy_Benefit_Manager_RX_BIN__c}'==''||'
{!Patient_Insurance__c.CoPay_Amount__c}'==''||'
{!Patient_Insurance__c.Coinsurance_Percent__c}'== ''||'{!Patient_Insurance__c.Deductable__c}'== ''||'{!Patient_Insurance__c.Deductible_Amount_Met__c}'== ''||'{!Patient_Insurance__c.OOP_Max__c}'==''||'
{!Patient_Insurance__c.OOP_Met__c}'== ''||'{!Patient_Insurance__c.Coinsurance_Percent__c}'=='')
{
alert('Please populate insurance and limit fields before procedding...');
}
else
{
window.location.href = '/500/e?cas4={!Patient_Insurance__c.Patient__c}&00Nc0000001BVbO= {!Patient_Insurance__c.Name}
&retURL=%2F500%2Fo&RecordType=012c00000000aXZ&ent=Case';
}
}
else
{
alert('The health plan category must be equal to Commercial.');
}

I have to pass a string that is a variable of a Javascript function to the new visualforce page controller using open.window. I know you can pass an explicit string value with open.window, like:

 

      var w=window.open('URL?variable=value')

 

and then use PageReference.getparameters to get the string. However, in mycase, the string comes from a Javascript onclick function, so the string value is known only at run-time. In the code below, I know that getparameters will just provide the string "drilldownparm", instead of the actual value of drilldownparm when the new page is opened. How can I pass the contents of drilldownparm to the new page?

 

Thanks.

 

 

  <script type="text/javascript">
    function drilldown(drilldownparm) {
       var w=window.open('/apex/CompetencyDrillDownPage?testvalue=drilldownparm',target='_blank')
       return false
    }
  </script>