• ankush
  • NEWBIE
  • 65 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 19
    Replies
I have a scenario where I am trying to run a method as a portal user and that method inturn creates a new account but when I try to do the same I am getting the below error can some one please help me.

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []
Hi Can anyone please guide how to run as community portal user in test class
I am having a scenario where I need to map the Text value to picklist like below. Can some one guide me how to do it

On VF page Picklist values Enter Color radio button option a and radio button option B

 but if they want to enter any other color than this we give them input text to enter manually and we want to map that input text to this picklist in database. How can I do that?
We have a radio button called employer not found and on click on that we are trying to display a div on the page using java script which is displaying properly.

But when custom validations fire the rerendering of the div block not happening. Can some one help us on this

Below is the code

Page.

 <apex:selectRadio value="{!employerchange}" layout="pageDirection" id="employerchange" 
                            onchange="Showdiv(this)">
                            <apex:selectOptions value="{!items3}" />
                        </apex:selectRadio>
                        <div id="empnotfound" 
                            style="visibility: hidden; position: absolute;">
                            <apex:outputLabel style="color:#174689;font-size:18px;"
                                value="Employer Details" />
                            <div class="half-line">
                                <br />
                            </div>
                            
                            <apex:outputLabel style="color:#3295ba;" value="Employer Name" />
                            <sup id="sup1">* </sup>
                            <apex:inputText id="empname" label="Employer Name"
                                value="{!empname}" html-placeholder=" Employer Name"
                                style="width:315px;margin-left:80px; {!empnamestyle}" required="false" />
                                
                             
                            <div class="half-line">
                            <br />
                            </div>
                            
                            <apex:outputLabel style="color:#3295ba;" value="Employer current Position" />
                            <sup id="sup1">* </sup>
                            <apex:inputText id="currentpos" label="Current Position"
                                html-placeholder=" Current Position" value="{!empcurrentpos}"
                                style="width:315px;margin-left:7px; {!empcurposstyle}" required="false" />
                                
                            <div class="half-line">
                                <br />
                            </div>
                            
                            <apex:outputLabel style="color:#3295ba;" value="Employer street" />
                            <sup id="sup1">* </sup>
                            <apex:inputText required="false" id="empStreet" label="Street"
                                html-placeholder=" Street" value="{!empstreet}"
                                style="margin-left:80px;width:315px {!empstreetstyle}" />
                            <br />
                            <div class="half-line">
                                <br />
                            </div>
                            
                            <apex:outputLabel style="color:#3295ba;" value="Employer city" />
                            <sup id="sup1">* </sup>
                            <apex:inputText required="false" id="empCity" label="City"
                                html-placeholder=" City" value="{!empcity}"
                                style="margin-left:95px;width:315px {!empcitystyle}" />
                            <br />
                            <div class="half-line">
                                <br />
                            </div>
                            <div>
                                <div style="display: inline-block">
                                    <apex:outputLabel style="color:#3295ba;" value="Employer State/Province" />
                                    <sup id="sup1">* </sup>
                                </div>
                                <div id="empstatetext"
                                    style="display: inline-block; visibility: hidden; position: absolute;">
                                    <apex:inputText id="empState" label="State" value="{!empstatetext}"
                                        html-placeholder=" State/Province" style="margin-left:16px;width:315px {!empstatetextstyle}"
                                        required="false" />
                                </div>
                                <div id="empstatelist"
                                    style="display: inline-block; visibility: hidden; position: absolute; margin-left: 16px;">
                                    <apex:selectList size="1" required="false" value="{!empstatelist}">
                                        <apex:selectOptions value="{!items6}" />
                                    </apex:selectList>

                                </div>
                            </div>
                            <div class="half-line">
                                <br />
                            </div>
                            <apex:outputLabel style="color:#3295ba;" value="Employer Country" />
                            <sup id="sup1">* </sup>
                            <apex:selectList size="1" required="false"
                                style="margin-left:63px;width:127px;" value="{!empcountry}"
                                onChange="empShowState(this)">
                                <apex:selectOptions value="{!items5}" />
                            </apex:selectList>
                            <div class="half-line">
                                <br />
                            </div>
                            <apex:outputLabel style="color:#3295ba;" value="Employer Zip/Postal Code" />
                            <sup id="sup1">* </sup>
                            <apex:inputText required="false" id="empZip" label="Zip"
                                html-placeholder=" Zip Code" value="{!empzip}"
                                style="margin-left:3px;width:315px {!empzipstyle}" />
                            <br />
                            <div class="half-line">
                                <br />
                            </div>


if(getrbtnvalue=='Employer not found')
  {
  document.getElementById('empnotfound').style.visibility='visible';
}

 
Can some one Guide how to write test case for the below.

  String userName = email;

        User u = new User();
        u.Username = userName;
        u.Email = email;
        u.FirstName = firstName;
        u.LastName = lastName;
        u.CommunityNickname = communityNickname;
        u.ProfileId = profileId;
       // u.phone=phone;
        
            String userId = Site.createPortalUser(u, accountId, password);
          
             if (userId != null) { 
            if (password != null && password.length() > 1) {
Can some one help me in auto populating account values on VF page if we start typing the existing account names in database in input field.

Like if I start typing JP thedn if JP morgan exists in database we need to auto populate all accounts starting with JP. Tried Jitendra Jaa Account JSON Creator but did not work. Tried another version also not working. Can some one help me with the code as stuck from long time
I have a scenario where there is long text area where people can enter  either Blue, green, Orange or all three together or any two of the three. Can some one help me to write a validation rule for the same.
I have a command button called send on my Vf page and requirement is to send email to the logged in user who is clicking that particular button. Can some one guide me how this can be done through apex code on thtat button Please stuck on this from long time.

Can anyone help me in understanding the steps remove the Save & new button from edit layout of oppurtunity as I have been stuck from long time. 
Hi All,

          We are looking to pre-populate Account Values in the database onto a VisualForce Page and that VisualForcepage is a self registration page to communities. This page opens through community link can some one guide if the pre-populating happens because the user trying to self register is not in the database until he logs in and we want the pre-populating on the self registration page before the login happens based on the accounts already in database.

Like if we have 
Coco cola
Apple
Google Accounts in database
if the user tries to enter App
then Apple should populate on the page
if he tries Goo all accounts with Goo should populate

Can some one help if this is possible if so then can some one help with the code.
  • April 24, 2015
  • Like
  • 0
Can some one Guide me How to redirect a page to VisualForce Tab with name Appl_Cntcs

I am trying the below but it is not opening

PageReference pr = new PageReference('/Appl_Cntcs/o');
      pr.setRedirect(true);
      return pr;

If I use the Visual force page it is redirecting but I am unable to see the tab hence need some help to redirect and also see the TAB.
  • April 13, 2015
  • Like
  • 0
Can some one Guide me How to redirect a page to VisualForce Tab with name Appl_Cntcs

I am trying the below but it is not opening

PageReference pr = new PageReference('/Appl_Cntcs/o');
      pr.setRedirect(true);
      return pr;
  • April 13, 2015
  • Like
  • 0
We have a scenario where a user needs to enter a form with some details like name email company. When he tries to enter company name that field should basically point to the Account names in salesforce database and like when he tries to enter say like goog the page needs to recognize the accounts with the names goog in database and may be populate something like google. when he tries entering ama it should populate like amazon (those accounts exists in datbase but trying to prepopulate.) Can some one guide me on this please how to accomlish this task.
  • March 24, 2015
  • Like
  • 0
I have a scenario where a custom button updates the value of picklist to a particular value when ever the button is clicked. The code was working fine. But had another requirement to have this custom button only work when the picklist values are not any value for two particular values. Hence I used the if condition but it is not working. Can some one guide me where I am going wrong.

Withouth the line in bold it is working for all picklist values but as informed above if I want to work only for particular two picklist I tried the statement in bold which is not updating anything.

{!requireScript("/soap/ajax/32.0/connection.js")} 
var er = new sforce.SObject("FC_Reviewer__External_Review__c"); 
er.id = "{!FC_Reviewer__External_Review__c.Id}"; 
if(er.FC_Reviewer__Status__c == "Ready To Review" || er.FC_Reviewer__Status__c== "Review In Progress") 
er.FC_Reviewer__Status__c="Review Submitted"; 
result = sforce.connection.update([er]); 
window.location.reload();
  • March 10, 2015
  • Like
  • 0
I have read in the communities guide that a contact can log into different communities with same username. But eloborate description not provided on the same. Does anyone have this requirement or if anyone implemented the same can you kindly guide me to have a knowledge on it how to go about it.
  • February 24, 2015
  • Like
  • 0
 Getting the error when validating
Future method cannot be called from a future or batch method: contactactivecheckboxclass.updatecnt(Set<String>) Trigger.Checkuseractive: line 18, column 1

ankush
Hi Tejpal,

       Tried the below code using your code given above the contactactivecheckboxclass1 error vanished but now the contactactivecheckboxclass causing the issue. Same issue. Can you please help me in the contactactive checkbox class if I had made any error.



Trigger.

//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after insert, after update) {
    set<string> set1 = new set<string>();
    set<string> set2 = new set<string>();
    if (!ProcessorControl.inFutureContext) {
        //Below soql query gets the IsActive and ContactId of the user
        list<user> u=[select id,Isactive,contactid from user where id=:trigger.new];
        for(user usr:u){
            if(usr.IsActive==false)
            {
            set1.add(usr.ContactId);
            }
            else if(usr.IsActive==true)
            {
            set2.add(usr.ContactId);
            }
        }
        contactactivecheckboxclass.Updatecnt(set1);
        contactactivecheckboxclass1.Updatecnt1(set2);
    }
}

Contactactive checkbox class
//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass {
    @future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt(set<string> x){
        try{
            list<contact> cntlist= new list<contact>();
            list<contact> c=[select Is_user_Active__c from Contact where id IN : x limit 1];
            for(contact cnt:c){
            cnt.Is_User_Active__c=false;
            if(!test.isrunningtest()){
                cntlist.add(cnt);
            }
            }
            ProcessorControl.inFutureContext = true;
            database.update(cntlist);
        }
        catch(exception e){
        }
    } 
}

Contact Active checjboxclass1

//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass1 {
    @future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt1(set<string> x){
        try{
            list<contact> cntlist= new list<contact>();
            list<contact> c=[select Is_user_Active__c from Contact where id IN : x limit 1];
            for(contact cnt:c){
            cnt.Is_User_Active__c=true;
            if(!test.isrunningtest()){
                 cntlist.add(cnt);
            }
            }
             ProcessorControl.inFutureContext = true;
            database.update(cntlist);
            }
        
        catch(exception e){
        }
    } 
}

Processor Control Class

public class ProcessorControl {
    public static boolean inFutureContext = false;
}
 
  • February 19, 2015
  • Like
  • 0
 Getting the error when validating
 Future method cannot be called from a future or batch method: contactactivecheckboxclass1.updatecnt1(Id) Trigger.Checkuseractive: line 15, column 1. Can some please guide

Trigger 
//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after insert, after update) {
   
    //Below soql query gets the IsActive and ContactId of the user
 list<user> u=[select id,Isactive,contactid from user where id=:trigger.new];
    for(user usr:u){
    Id cid=usr.ContactId;
    if(usr.IsActive==false)
    {
        contactactivecheckboxclass.Updatecnt(cid);
        
    }
        else if(usr.IsActive==true)
    {
        contactactivecheckboxclass1.Updatecnt1(cid);
        
    }
        }
}

Class

//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass1 {
@future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
     public static void updatecnt1(id x){
         try{
    contact c=[select Is_user_Active__c from Contact where id=:x limit 1];
    c.Is_User_Active__c=true;
    if(!test.isrunningtest()){

        database.update(c);
         }
         }
         catch(exception e){
          
          
      }
   } 
}
  • February 19, 2015
  • Like
  • 0

The Old Code and new code functionality is same to have to update the checkbox on contact based on active on user.
Old one does not have code to make active and new one has that one and also instead of using trigger.new[0].Id I modified to trigger.new in new code it is working fine but when I upload to prod and try to validate getting the below error for other classes.
List has no rows for assignment for SObject on contactactivecheckboxclass1.updatect1 line 6
List has no rows for assignment for SObject on contactactivecheckboxclass.updatect line 6


Can you guide me to rectify this.
Old Code trigger:
//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after update) {
   
    //Below soql query gets the IsActive and ContactId of the user
 user u=[select id,Isactive,contactid from user where id=:trigger.new[0].id limit 1];
    Id cid=u.ContactId;
    if(trigger.new[0].IsActive==false)
    {
        contactactivecheckboxclass.Updatecnt(cid);
    }
}
Old Code Class
//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass {
@future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt(id x){
    contact c=[select Is_user_Active__c from Contact where id=:x limit 1];
    c.Is_User_Active__c=false;
    if(!test.isrunningtest()){
        database.update(c);
         }
   } 
}
New Code trigger:
//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after update) {
   
    //Below soql query gets the IsActive and ContactId of the user
 list<user> u=[select id,Isactive,contactid from user where id=:trigger.new];
    for(user usr:u){
    Id cid=usr.ContactId;
    if(usr.IsActive==false)
    {
        contactactivecheckboxclass.Updatecnt(cid);
        
    }
        else if(usr.IsActive==true)
    {
        contactactivecheckboxclass1.Updatecnt1(cid);
        
    }
        }
}
New Code Class1
//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass {
@future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt(id x){
    contact c=[select Is_user_Active__c from Contact where id=:x limit 1];
        system.debug('The contact is' + c);
    c.Is_User_Active__c=false;
    if(!test.isrunningtest()){
        database.update(c);
         }
   } 
    
    
}
New Code Class2
//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass1 {
@future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
     public static void updatecnt1(id x){
    contact c=[select Is_user_Active__c from Contact where id=:x limit 1];
    c.Is_User_Active__c=true;
    if(!test.isrunningtest()){
        database.update(c);
         }
   } 
}
  • February 19, 2015
  • Like
  • 0
Can some one please help me how to avooid the soql query in the last for loop to assign user id. Stuck on this

trigger COITrigger on Panel_Assignment__c (after insert, after update, after delete, before delete) {
    
    //If Panel Assignment is inserted then we have COI inserted along with Status as Active
    if(Trigger.isafter && trigger.isInsert){
       Set<Id> panelIds = new Set<Id>();
        list<COI_Expertise__c> coilist=new list<COI_Expertise__c>();
        for ( Panel_Assignment__c panelAssignment : Trigger.new) {
            // Store all panel's Id
            panelIds.add(panelAssignment.Panel__c);
        }
         //Below soql query fetches the related Research Applications
         //Also based on research applications the COI records are created for each reviewer assigned to the panel.
         
   list<Research_Application__c> r=[select id,Technical_Abstract__c from Research_Application__c where Panel__c=:panelIds];
       for(Research_Application__c ra:r){
           for(Panel_Assignment__c panelAssignment : Trigger.new){
        COI_Expertise__c  c=new COI_Expertise__c();
        c.Research_Application__c= ra.Id;
    c.Technical_Abstract__c=ra.Technical_Abstract__c;
           c.Active__c=true; 
         c.Reviewer_Name__c = panelAssignment.Reviewer_Name__c;
               

               user u=[select id,firstname,lastname from user where contactID=:c.Reviewer_Name__c];
                        c.OwnerId=u.Id;
           
               coilist.add(c);
                
               }
             }    
         
insert coilist;  
    }
  • February 05, 2015
  • Like
  • 0
Can some one please help me how to avoid soql queries inside for loop. The below code working fine. Same functionality to work without soql queries iside for loop. Stuck on this.
 
if(trigger.isbefore && trigger.isdelete)
    {
     
       list<COI_Expertise__c> coilist=new list<COI_Expertise__c>();
       list<panel_assignment__c> lp=[select Reviewer_Name__c,Panel__c,Active__c from panel_assignment__C where id=:Trigger.old];
        system.debug('The list is' +  lp);
   for(panel_assignment__c l:lp){
       Id ReviewerId=l.Reviewer_Name__c;
    Id PanelId=l.Panel__c;
   list<Research_Application__c> r=[select id from Research_Application__c where Panel__c=:panelId];
       for(Research_Application__c ra:r){
       Id rschappId=ra.Id;
           list<COI_Expertise__c> ci=[Select id,Reviewer_Name__c from COI_Expertise__c where Research_Application__c=:rschappId];
           for(COI_Expertise__c ce:ci){
               if(ReviewerId==ce.Reviewer_Name__c)
       ce.Active__c=false;
       coilist.add(ce);
   }
           }
       }
        update coilist;
    }
  • February 04, 2015
  • Like
  • 0
I have a scenario where I am trying to run a method as a portal user and that method inturn creates a new account but when I try to do the same I am getting the below error can some one please help me.

System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []
Hi Can anyone please guide how to run as community portal user in test class
I have a scenario where there is long text area where people can enter  either Blue, green, Orange or all three together or any two of the three. Can some one help me to write a validation rule for the same.
Can some one Guide me How to redirect a page to VisualForce Tab with name Appl_Cntcs

I am trying the below but it is not opening

PageReference pr = new PageReference('/Appl_Cntcs/o');
      pr.setRedirect(true);
      return pr;

If I use the Visual force page it is redirecting but I am unable to see the tab hence need some help to redirect and also see the TAB.
  • April 13, 2015
  • Like
  • 0
I have a scenario where a custom button updates the value of picklist to a particular value when ever the button is clicked. The code was working fine. But had another requirement to have this custom button only work when the picklist values are not any value for two particular values. Hence I used the if condition but it is not working. Can some one guide me where I am going wrong.

Withouth the line in bold it is working for all picklist values but as informed above if I want to work only for particular two picklist I tried the statement in bold which is not updating anything.

{!requireScript("/soap/ajax/32.0/connection.js")} 
var er = new sforce.SObject("FC_Reviewer__External_Review__c"); 
er.id = "{!FC_Reviewer__External_Review__c.Id}"; 
if(er.FC_Reviewer__Status__c == "Ready To Review" || er.FC_Reviewer__Status__c== "Review In Progress") 
er.FC_Reviewer__Status__c="Review Submitted"; 
result = sforce.connection.update([er]); 
window.location.reload();
  • March 10, 2015
  • Like
  • 0
 Getting the error when validating
Future method cannot be called from a future or batch method: contactactivecheckboxclass.updatecnt(Set<String>) Trigger.Checkuseractive: line 18, column 1

ankush
Hi Tejpal,

       Tried the below code using your code given above the contactactivecheckboxclass1 error vanished but now the contactactivecheckboxclass causing the issue. Same issue. Can you please help me in the contactactive checkbox class if I had made any error.



Trigger.

//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after insert, after update) {
    set<string> set1 = new set<string>();
    set<string> set2 = new set<string>();
    if (!ProcessorControl.inFutureContext) {
        //Below soql query gets the IsActive and ContactId of the user
        list<user> u=[select id,Isactive,contactid from user where id=:trigger.new];
        for(user usr:u){
            if(usr.IsActive==false)
            {
            set1.add(usr.ContactId);
            }
            else if(usr.IsActive==true)
            {
            set2.add(usr.ContactId);
            }
        }
        contactactivecheckboxclass.Updatecnt(set1);
        contactactivecheckboxclass1.Updatecnt1(set2);
    }
}

Contactactive checkbox class
//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass {
    @future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt(set<string> x){
        try{
            list<contact> cntlist= new list<contact>();
            list<contact> c=[select Is_user_Active__c from Contact where id IN : x limit 1];
            for(contact cnt:c){
            cnt.Is_User_Active__c=false;
            if(!test.isrunningtest()){
                cntlist.add(cnt);
            }
            }
            ProcessorControl.inFutureContext = true;
            database.update(cntlist);
        }
        catch(exception e){
        }
    } 
}

Contact Active checjboxclass1

//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass1 {
    @future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
    public static void updatecnt1(set<string> x){
        try{
            list<contact> cntlist= new list<contact>();
            list<contact> c=[select Is_user_Active__c from Contact where id IN : x limit 1];
            for(contact cnt:c){
            cnt.Is_User_Active__c=true;
            if(!test.isrunningtest()){
                 cntlist.add(cnt);
            }
            }
             ProcessorControl.inFutureContext = true;
            database.update(cntlist);
            }
        
        catch(exception e){
        }
    } 
}

Processor Control Class

public class ProcessorControl {
    public static boolean inFutureContext = false;
}
 
  • February 19, 2015
  • Like
  • 0
 Getting the error when validating
 Future method cannot be called from a future or batch method: contactactivecheckboxclass1.updatecnt1(Id) Trigger.Checkuseractive: line 15, column 1. Can some please guide

Trigger 
//This is a trigger that is used to check whether the user is active and updates the related Contact
trigger Checkuseractive on User (after insert, after update) {
   
    //Below soql query gets the IsActive and ContactId of the user
 list<user> u=[select id,Isactive,contactid from user where id=:trigger.new];
    for(user usr:u){
    Id cid=usr.ContactId;
    if(usr.IsActive==false)
    {
        contactactivecheckboxclass.Updatecnt(cid);
        
    }
        else if(usr.IsActive==true)
    {
        contactactivecheckboxclass1.Updatecnt1(cid);
        
    }
        }
}

Class

//Future class for updating Contact Active Checkbox field
public class contactactivecheckboxclass1 {
@future
    //Method that takes the contact id as parameter from Trigger and checks if user is active on user Object and updates the related contact accordingly.
     public static void updatecnt1(id x){
         try{
    contact c=[select Is_user_Active__c from Contact where id=:x limit 1];
    c.Is_User_Active__c=true;
    if(!test.isrunningtest()){

        database.update(c);
         }
         }
         catch(exception e){
          
          
      }
   } 
}
  • February 19, 2015
  • Like
  • 0
Can some one please help me how to avooid the soql query in the last for loop to assign user id. Stuck on this

trigger COITrigger on Panel_Assignment__c (after insert, after update, after delete, before delete) {
    
    //If Panel Assignment is inserted then we have COI inserted along with Status as Active
    if(Trigger.isafter && trigger.isInsert){
       Set<Id> panelIds = new Set<Id>();
        list<COI_Expertise__c> coilist=new list<COI_Expertise__c>();
        for ( Panel_Assignment__c panelAssignment : Trigger.new) {
            // Store all panel's Id
            panelIds.add(panelAssignment.Panel__c);
        }
         //Below soql query fetches the related Research Applications
         //Also based on research applications the COI records are created for each reviewer assigned to the panel.
         
   list<Research_Application__c> r=[select id,Technical_Abstract__c from Research_Application__c where Panel__c=:panelIds];
       for(Research_Application__c ra:r){
           for(Panel_Assignment__c panelAssignment : Trigger.new){
        COI_Expertise__c  c=new COI_Expertise__c();
        c.Research_Application__c= ra.Id;
    c.Technical_Abstract__c=ra.Technical_Abstract__c;
           c.Active__c=true; 
         c.Reviewer_Name__c = panelAssignment.Reviewer_Name__c;
               

               user u=[select id,firstname,lastname from user where contactID=:c.Reviewer_Name__c];
                        c.OwnerId=u.Id;
           
               coilist.add(c);
                
               }
             }    
         
insert coilist;  
    }
  • February 05, 2015
  • Like
  • 0
Can some one please help me how to avoid soql queries inside for loop. The below code working fine. Same functionality to work without soql queries iside for loop. Stuck on this.
 
if(trigger.isbefore && trigger.isdelete)
    {
     
       list<COI_Expertise__c> coilist=new list<COI_Expertise__c>();
       list<panel_assignment__c> lp=[select Reviewer_Name__c,Panel__c,Active__c from panel_assignment__C where id=:Trigger.old];
        system.debug('The list is' +  lp);
   for(panel_assignment__c l:lp){
       Id ReviewerId=l.Reviewer_Name__c;
    Id PanelId=l.Panel__c;
   list<Research_Application__c> r=[select id from Research_Application__c where Panel__c=:panelId];
       for(Research_Application__c ra:r){
       Id rschappId=ra.Id;
           list<COI_Expertise__c> ci=[Select id,Reviewer_Name__c from COI_Expertise__c where Research_Application__c=:rschappId];
           for(COI_Expertise__c ce:ci){
               if(ReviewerId==ce.Reviewer_Name__c)
       ce.Active__c=false;
       coilist.add(ce);
   }
           }
       }
        update coilist;
    }
  • February 04, 2015
  • Like
  • 0
Hi can some one help me in rectifying the code.

I am trying to update contacts and getting the above error. I have around 4000 contacts.


trigger Updateuserprofile on contact (after update) {
    string text1=Label.New_Reviewer;
      String recordTypeName = Label.Contact_Record_Type; 
  Map<String,Schema.RecordTypeInfo> rtMapByName = Schema.SObjectType.Contact.getRecordTypeInfosByName();
  Schema.RecordTypeInfo rtInfo =  rtMapByName.get(recordTypeName);
  id recordTypeId = rtInfo.getRecordTypeId();
    
    if(Trigger.isafter && trigger.isUpdate)
    {
          if(recursiveTrigger.runOnce()){
              
  for(contact cnt:trigger.new){
      if(cnt.recordtypeID==recordTypeId){
          if(cnt.Reviewer_Status__c==null){
              
          }
              
  else if( cnt.Reviewer_Status__c.equals(text1) ){
      try{
          list<User> u=[select Id,Email,Username from User where contactid=:cnt.Id];
          for(user usr:u){
           updateuserinformation.updateuser(usr.Id);
              }
}
      catch(exception e){
          
          
      }
    
}
   
      
}
    }  
  }
     
}
    }
 
  • January 30, 2015
  • Like
  • 0

Is there anyway to remove/hide the standard Save & New button on the edit page of Salesforce.

 

I don't want this action for my User and I don't have control over the standard edit page layout of Salesforce unlike the detail page layout. Please let me now if this is possible in some ways in the standard Salesforce page itself.

 

Regards,

Karthik.