• Rajat Mahajan
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 19
    Replies

Hey Guys!

 

Needed a bit help in this.

 

I am trying to upload some csv fiels in a custom object from Dataloader (bulk operation).

The filename of the csv is actually an employee number field of the user object.

 

While uploading this file in the custom object i need to extract that employee number (which is the filename) and make the record owner that user.

 

Can you help me out with how to code this thing in a trigger ?

 

Thanks a bunch !

Hi All, 

 

We are trying to connect Account to a custom object Purchase Order in a One to Many Relation. A custom field called account number will be auto populated in Purchase Order from Account object. But while saving the record we are getting a "Cant update a read only record" exception.

 

Had read some more posts on this exception, but we were not clear on that.

 

The code is :

 

trigger IntegratePOtoAccount on Purchase_Order__c (after insert, after update) {

//Declare Variables
public Map<Id,Id> poAccountId = new Map<Id, Id>();
public Map<Id,String> accIDAccNumber = new Map<Id, String>();
public List<Account> accountList = new List<Account>();
public List<Purchase_Order__c> poList = new List<Purchase_Order__c>();
public Purchase_Order__c po_rec;
public Id accountId;
public String accountNumber;

 
    //Fetch the account id from Purchase Order
    for(Purchase_Order__c po : trigger.new) {
    System.debug('po is'+po.Id);
    System.debug('po is 2'+po.Account__c);
       poAccountId.put(po.Id,po.Account__c);
    }

    //Query all records of account to create a map
    accountList = [Select Id, name, account_number__c from account];

    //Put all the accounts in a map from Id to account  number
    for(Account acc : accountList) {
        accIDAccNumber.put(acc.Id, acc.account_number__c);
    }

    //Insert the Account Number for each PO
    for(Purchase_Order__c po : trigger.new) {
        accountId = poAccountId.get(po.Id);
        accountNumber = accIDAccNumber.get(accountId);
        po.oracle_account_number__c = accountNumber;
    }

}

 

Could you please let us know how to tackle this. we get an error at the last line po.oracle_account_number__c = accountNumber;

 

Thanks in Advance!

Rajat

Hi,

 

We have a requirement for an apex batch job :

 

1. Accounts object has a child object called (Purchase_Order__c) in a master detail relation

2. If we manually share accounts to a public group. the public group should have access to the PO also.

3. And if we remove that public group form the account we need to remove that sharing from PO too.

 

Could you help me with a sample code?

 

Regards

Rajat

Hi All,

 

Could you help me with the following piece of code :

 

----------------------------------------------------------------------------------------------------------

 

if(acclst.size()>0) {

for(Account acc:acclst) {

//Check if Account have contact/Opportunity associated with it
opplst = [select Id,AccountId from Opportunity where AccountId =:acc.Id];
conlst = [select Id from Contact where AccountId in:acc.Id];

if(opplst.size()==0&&conlst.size()==0) {
/*
* If Account do not have the contacts and opportunities associated to it
* then add those account Ids in the set
*/

sAccId.add(acc.Id);
}
else {
sAccId_CO.add(acc.Id);
}

}

-----------------------------------------------------------------------------------------------------

 

The problem : I am running this through a trigger, and since a query should not be in loops i am hitting TOO MANY SQL QUERY exception. Could you please have a look at the code and modify it to make it work for me ?

 

Your help will be really appreciated,

Rajat

Hi,

 

I have a public group in which i need to add only the salesforce user license users. 

 

Can you guys let me know the best approach to do this ? Its very hectic to do it manually

 

Thanks in Advance!

Rajat

Hey Guys, 

 

Could you please help me construct one bulk trigger ?

 

I am trying to achieve a requirement :

 

Before deletes on Account, we need the trigger to check if the Account has any opportunities on the Account. If the Account has opportunities, we need to prevent the deletion and move on to the next record.

 

Regards

Rajat

 

 

 

Hi All,

 

I would really appreciate it if someone can please help me bulkify the following code:

 

/*Trigger name : InsertOppTeam
*
* Author : Rajat Mahajan
*
* Description : This is to insert Opportunity Team while inserting or updating Opportunitys.
*/

trigger InsertOppTeam on Opportunity (after insert, after update) {

Set<Id> idOpp = new Set<Id>();
Set<Id> OppEndCustomerId = new Set<Id>();
List<OpportunityTeamMember> lstOppTeam = new List<OpportunityTeamMember>();

//Declare Variables to query Account Directory and then the Account Owner from User Object
User userRec = new User();
Account_Info__c accountRec = new Account_Info__c();

System.debug('Testing out Trigger.New Content Debug 1 : ' + Trigger.New);

for(Opportunity newOpp : trigger.new) {
if(newOpp.End_Customer__c != null) {
idOpp.add(newOpp.Id);
OppEndCustomerId.add(newOpp.End_Customer__c);
accountRec = [select id, Account_Manager__c from Account_Info__c where id in:OppEndCustomerId limit 1];
userRec = [select Id from User where isActive = true and name = :accountRec.Account_Manager__c];

OpportunityTeamMember tm = new OpportunityTeamMember();
tm.UserId = userRec.Id;
tm.OpportunityId = newOpp .Id;
insert tm;
}
}

}

 

It would be great if you can help me out please.

 

Regards

Rajat

Hi,

 

I have a salesforce requirement where i need to sort values of a column in a vf page (pageblocktable columns) by clicking the header value of the columns.

 

Could you please let me know how to achieve this with a sample code

 

Thanks in Advance

Rajat.

Hi All,

 

I am having two picklist fields in my vf page.

 

The values of the both the picklist are hard coded and the options are rendered according to a custom setting object which is having some boolean values.

 

The requirement is that if i select a value in the first picklist, then onclick of the first picklist value, the second picklist should not have the same option available,

 

Could you please let me know how to proceed with this.

 

Thanks in Advance,

Rajat.

Hi All,

 

I have a custom object program consisting of products (child object)

 

All products have different expiry dates. Even a program has a expiry date.

 

When a program expiry date comes for a product then that product converts into an opportunity also,

the products associated with it get converted into that opportunity (products).

 

IF product have different end dates than program dates, then they should be created as a different opportunity, else they would remain in the same opportunity.

 

Please help out.

 

Regards

Rajat.

Hi All,

 

I have been trying to develop the following functionality in a pageblocktable (not using the repeat tag)

 

What i need is :

1. Whenever i click on a particular record, that record should get converted to all input fields leaving the rest of the records in a non editable mode.

2. I can change all values for that particular record and click the save button next to it that will rerender the page with new values.

 

However, i have failed to do so,

 

could you please help out ?

 

Following is my code :

 page ===========================================================================

 

<apex:page controller="EditAccount">
<script type="text/javascript">
function HideShow(rId,Id,mode)
{
    var rowId = rId;
    var accountId = Id;
    var editrowId = 'edit:'+ Id;
    if(mode == 'n')
    {
        document.getElementById(rowId).style.display = 'none';
        document.getElementById(editrowId).style.display = 'block';
    }
    else if(mode == 'e')
    {       
        var rrowId = 'detail:'+ Id; 
        document.getElementById(rrowId).style.display = 'block';
        document.getElementById(rowId).style.display = 'none'; 
    }
}
</script>
<apex:form >
    <apex:outputPanel id="opnl">
 <apex:pageBlock >
         <div style="width:100%">        
                 <apex:pageblockTable value="{!account}" var="a" id="table1" columns="2" style="width:150%">
     <div id="detail:{!a.id}" style="width:61%;display:block;" ondblclick="HideShow(this.id,'{!a.id}','n');">         
               <apex:column headervalue=" First Name" colspan="1" rowspan="1" width="100" >                      
                     <apex:outputField id="firstname" value="{!a.name}" />
                   </apex:column>              
                    <apex:column headervalue=" Last Name" colspan="1" rowspan="1" width="100">                      
                    <apex:outputField id="lastname" value="{!a.phone}" />
                   </apex:column>       
      </div>
       </apex:pageblockTable>
          <apex:pageblockTable value="{!account}" var="a" id="table2" columns="4" style="width:150%">
                <div id="edit:{!a.id}" style="width:35%;display:none;" >               
                 <apex:column headervalue=" First Name" colspan="1" rowspan="1" width="100" >                      
                     <apex:inputfield id="firstname" value="{!a.name}" />
                   </apex:column>                  
                    <apex:column headervalue=" Last Name" colspan="1" rowspan="1" width="100">                      
                    <apex:inputfield id="lastname" value="{!a.phone}" />
                   </apex:column>
                            <apex:column >   
                  <apex:commandButton id="savebutton" value="Save" onclick="HideShow('edit','{!a.id}','e');savedata('{!a.id}');"/>  
                  <apex:commandButton onclick="HideShow('edit','{!a.id}','e');" id="cancelButton" value="Cancel"/>              
               </apex:column>       
               </div>
              </apex:pageblockTable>           
      </div>
      </apex:pageBlock>  
</apex:outputPanel>
   <input id="xyz" type="hidden" onclick="ppppp();" />
    <apex:actionFunction id="saveaccount" name="savedata" action="{!doSave}" reRender="opnl"  />
      <apex:param name="accountsave" assignTo="{!propviewdata}" value=""/>
   </apex:form>
</apex:page>

 

======================================================================================

 

class =================================================================================

 

public class EditAccount
{
    public List<Account> acc;
   
    public void doSave()
    {  
        for(account ac : acc)
        {
           update ac;
        }
    }
    public List<Account> getAccount()  
    {
       return (List<Account>) acc;
    }//End getAccount
   
    public void setAccount(List<Account> Acc)
    {
     this.acc = Acc;
    } 
  
    public EditAccount()
    {
        acc = [select id,Name, Phone,BillingCity,CreatedDate from Account limit 1000];
    }//End Constructor

}

 

Warm Regards

Rajat

Hi All,

 

I have a custom Visual force page consisting of pageblock section with some information.

 

I wanted to have alphabetic ordering just the way it is done in the standard object page layouts, for the list i have in this pageblock section

 

Is there a way to do this?

Please help me out.

 

Thanks

Rajat.

Hi all,

 

i have the following piece of code which runs when i try to deactivate a user :

 

=================================TRIGGER=======================================================

trigger closeTargetProspect on User (after Update) {

public List<Targets__c> Target_list = new list<targets__c>();

for (User u : trigger.new) {

if(!u.isActive) {

Target_list=[select id,Target_Start_Date__c, Target_End_Date__c, Contact_Owner__c from Targets__c where ownerid = :u.id and Target_End_Date__c = null];

for(targets__c t : Target_list)
{
    t.Target_End_Date__c= date.today();
}
if(target_list.size()>0)
{
    update Target_List;
}
}

}

}

=======================================END====================================================

 

When i deactivate the user, i get an error message :

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger closeTargetProspect caused an unexpected exception, contact your administrator: closeTargetProspect: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a09900000022LPDAA2; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Targets__c, original object: User: []: Trigger.closeTargetProspect: line 17, column 1

 

I had read some articles on MIXED_DML_OPERATION on community, but i am unable to get how to change this code to make it work

 

a piece of code i had found was :

 

===============================================================================================

 

private static void myFunc()

{

     ///1st DML operation

 

     User usr = [Select id from User where Id = :UserInfo.getUserId()];

 

     System.RunAs(usr)

     {

        Test.startTest();

         myFunc2();

         Test.stopTest();

     }

 

 

}

 

@future

private static void myFunc2()

{

   ///2nd DML operation

}

 

============================================================================================

 

I am not sure how to implement the methods in this trigger or how to make a call from this trigger to a seperate class where this method belongs.

 

Could you please help me out with changing the code?

 

Thanks in Advance

Rajat.

Hi All,

 

I had deactivated a user, which i want to activate once again.

 

However, i am not ablr to find that user in "All Users List"

 

Could you please tell me the steps to re-activate the user

 

Thanks in Advance

Rajat

Hi All,

 

I am not able to see the custom links that i have provided in an inline vf page on standard contact object layout in salesforce mobile app

 

i had read somewhere that we cannot see inline vf in mobiles.

 

The problem is : i am trying to achieve a functionality which is user specific, it can be done only on inline vf pages and not on the standard page

 

Please help

 

Regards

Rajat

Hi

 

I am trying to use the following code, which is not allowing me to save the entry, i am redirected to the home  page after i click on save, when i go back to the page, i see the old values

 

Request you to please help me with this :

 

Visual Force Page ================================================================================

 

<apex:page standardController="Account" recordSetvar="accounts" extensions="AccountPagination">
  <apex:pageBlock title="Viewing Accounts" >
  <apex:form id="theForm">
    <apex:pageBlockSection >
    <!--  <apex:dataList var="a" value="{!accountPagination}" type="1">
        {!a.name}
         
        </apex:dataList>  -->
         <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
        
         <apex:pageblockTable value="{!accountPagination}" var="e" id="table2" columns="21" style="width:130%">
          
                  <apex:column headervalue="Accounts">
                        <apex:outputField id="accounts" value="{!e.name}"/> &nbsp;
                     </apex:column>
                           
               </apex:pageblockTable>
        
              <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
    
    </apex:pageBlockSection>
    <apex:panelGrid columns="2">
      <apex:commandLink action="{!previous}">Previous</apex:commandlink>
      <apex:commandLink action="{!next}">Next</apex:commandlink>
    </apex:panelGrid>
  </apex:form>
  </apex:pageBlock>
</apex:page>

 

Apex Class ======================================================================================

 

public with sharing class AccountPagination {
    private final Account acct;  

    // The constructor passes in the standard controller defined below
    
 // in the Visualforce markup
    
    public AccountPagination(ApexPages.StandardSetController controller) {
       this.acct = (Account)controller.getRecord();
    }    
    
    public ApexPages.StandardSetController accountRecords{
        get {
            if(accountRecords == null) {
                return new ApexPages.StandardSetController(Database.getQueryLocator(
                [SELECT name FROM Account WHERE Id NOT IN (SELECT AccountId
                FROM Opportunity WHERE IsClosed = false) limit : 20]));
            }
            return accountRecords;
        }
        private set;
    }
    public List<Account> getAccountPagination() {
         return (List<Account>) accountRecords.getRecords();
    }  
}

Hi All,

 

I am trying to pass a picklist value into a sql query "order by" clause

 

However i am not able to use the syntax :

 

:<variable name> in order by

 

Could you please suggest me a solution to this

 

Regards

Rajat.

Hi All,

 

I am trying to achieve inline editing feature for a requirement.

 

I have a sample code as below :

 

<apex:page standardController="Contact">  
 <apex:form >  
 <apex:pageBlock mode="inlineEdit">  
     <apex:pageBlockButtons >  
     <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>  
     <apex:commandButton action="{!save}" id="saveButton" value="Save"/>  
     <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>  
     </apex:pageBlockButtons>  
 <apex:pageBlockSection >  
     <apex:outputField value="{!contact.lastname}">  
         <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"  
             hideOnEdit="editButton" event="ondblclick"  
             changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>  
     </apex:outputField>  
     <apex:outputField value="{!contact.accountId}"/>  
     <apex:outputField value="{!contact.phone}"/>  
 </apex:pageBlockSection>  
 </apex:pageBlock>  
 </apex:form>  
 </apex:page>

 

The only thing that i have a problem is that in order to change a contact i have to append the url everytime with a contact id.

 

That works only in case of one record.


I have a visual force page, which display lot of contact records in a pageblocksection. How would i pass the id for the record i am editing and saving to this, as i would have many records

 

Could you please help me out with this requirement

 

Thanks,

Rajat.

Hi All,

 

I have a requirement where an admin user can delete the columns from a pageblocktable on the ui, without changing the code.

 

The admin user should be able to do this from the user interface.

 

Could you please tell me if this is feasible and how ?

 

Thanks in advance

Hi All,

 

I have a custom Visual force page consisting of pageblock section with some information.

 

I wanted to have alphabetic ordering just the way it is done in the standard object page layouts, for the list i have in this pageblock section

 

Is there a way to do this?

Please help me out.

 

Thanks

Rajat.

Hi All, 

 

We are trying to connect Account to a custom object Purchase Order in a One to Many Relation. A custom field called account number will be auto populated in Purchase Order from Account object. But while saving the record we are getting a "Cant update a read only record" exception.

 

Had read some more posts on this exception, but we were not clear on that.

 

The code is :

 

trigger IntegratePOtoAccount on Purchase_Order__c (after insert, after update) {

//Declare Variables
public Map<Id,Id> poAccountId = new Map<Id, Id>();
public Map<Id,String> accIDAccNumber = new Map<Id, String>();
public List<Account> accountList = new List<Account>();
public List<Purchase_Order__c> poList = new List<Purchase_Order__c>();
public Purchase_Order__c po_rec;
public Id accountId;
public String accountNumber;

 
    //Fetch the account id from Purchase Order
    for(Purchase_Order__c po : trigger.new) {
    System.debug('po is'+po.Id);
    System.debug('po is 2'+po.Account__c);
       poAccountId.put(po.Id,po.Account__c);
    }

    //Query all records of account to create a map
    accountList = [Select Id, name, account_number__c from account];

    //Put all the accounts in a map from Id to account  number
    for(Account acc : accountList) {
        accIDAccNumber.put(acc.Id, acc.account_number__c);
    }

    //Insert the Account Number for each PO
    for(Purchase_Order__c po : trigger.new) {
        accountId = poAccountId.get(po.Id);
        accountNumber = accIDAccNumber.get(accountId);
        po.oracle_account_number__c = accountNumber;
    }

}

 

Could you please let us know how to tackle this. we get an error at the last line po.oracle_account_number__c = accountNumber;

 

Thanks in Advance!

Rajat

Hi All,

 

Could you help me with the following piece of code :

 

----------------------------------------------------------------------------------------------------------

 

if(acclst.size()>0) {

for(Account acc:acclst) {

//Check if Account have contact/Opportunity associated with it
opplst = [select Id,AccountId from Opportunity where AccountId =:acc.Id];
conlst = [select Id from Contact where AccountId in:acc.Id];

if(opplst.size()==0&&conlst.size()==0) {
/*
* If Account do not have the contacts and opportunities associated to it
* then add those account Ids in the set
*/

sAccId.add(acc.Id);
}
else {
sAccId_CO.add(acc.Id);
}

}

-----------------------------------------------------------------------------------------------------

 

The problem : I am running this through a trigger, and since a query should not be in loops i am hitting TOO MANY SQL QUERY exception. Could you please have a look at the code and modify it to make it work for me ?

 

Your help will be really appreciated,

Rajat

Hi,

 

I have a public group in which i need to add only the salesforce user license users. 

 

Can you guys let me know the best approach to do this ? Its very hectic to do it manually

 

Thanks in Advance!

Rajat

Hey Guys, 

 

Could you please help me construct one bulk trigger ?

 

I am trying to achieve a requirement :

 

Before deletes on Account, we need the trigger to check if the Account has any opportunities on the Account. If the Account has opportunities, we need to prevent the deletion and move on to the next record.

 

Regards

Rajat

 

 

 

Hi All,

 

I would really appreciate it if someone can please help me bulkify the following code:

 

/*Trigger name : InsertOppTeam
*
* Author : Rajat Mahajan
*
* Description : This is to insert Opportunity Team while inserting or updating Opportunitys.
*/

trigger InsertOppTeam on Opportunity (after insert, after update) {

Set<Id> idOpp = new Set<Id>();
Set<Id> OppEndCustomerId = new Set<Id>();
List<OpportunityTeamMember> lstOppTeam = new List<OpportunityTeamMember>();

//Declare Variables to query Account Directory and then the Account Owner from User Object
User userRec = new User();
Account_Info__c accountRec = new Account_Info__c();

System.debug('Testing out Trigger.New Content Debug 1 : ' + Trigger.New);

for(Opportunity newOpp : trigger.new) {
if(newOpp.End_Customer__c != null) {
idOpp.add(newOpp.Id);
OppEndCustomerId.add(newOpp.End_Customer__c);
accountRec = [select id, Account_Manager__c from Account_Info__c where id in:OppEndCustomerId limit 1];
userRec = [select Id from User where isActive = true and name = :accountRec.Account_Manager__c];

OpportunityTeamMember tm = new OpportunityTeamMember();
tm.UserId = userRec.Id;
tm.OpportunityId = newOpp .Id;
insert tm;
}
}

}

 

It would be great if you can help me out please.

 

Regards

Rajat

Hi All,

 

I have been trying to develop the following functionality in a pageblocktable (not using the repeat tag)

 

What i need is :

1. Whenever i click on a particular record, that record should get converted to all input fields leaving the rest of the records in a non editable mode.

2. I can change all values for that particular record and click the save button next to it that will rerender the page with new values.

 

However, i have failed to do so,

 

could you please help out ?

 

Following is my code :

 page ===========================================================================

 

<apex:page controller="EditAccount">
<script type="text/javascript">
function HideShow(rId,Id,mode)
{
    var rowId = rId;
    var accountId = Id;
    var editrowId = 'edit:'+ Id;
    if(mode == 'n')
    {
        document.getElementById(rowId).style.display = 'none';
        document.getElementById(editrowId).style.display = 'block';
    }
    else if(mode == 'e')
    {       
        var rrowId = 'detail:'+ Id; 
        document.getElementById(rrowId).style.display = 'block';
        document.getElementById(rowId).style.display = 'none'; 
    }
}
</script>
<apex:form >
    <apex:outputPanel id="opnl">
 <apex:pageBlock >
         <div style="width:100%">        
                 <apex:pageblockTable value="{!account}" var="a" id="table1" columns="2" style="width:150%">
     <div id="detail:{!a.id}" style="width:61%;display:block;" ondblclick="HideShow(this.id,'{!a.id}','n');">         
               <apex:column headervalue=" First Name" colspan="1" rowspan="1" width="100" >                      
                     <apex:outputField id="firstname" value="{!a.name}" />
                   </apex:column>              
                    <apex:column headervalue=" Last Name" colspan="1" rowspan="1" width="100">                      
                    <apex:outputField id="lastname" value="{!a.phone}" />
                   </apex:column>       
      </div>
       </apex:pageblockTable>
          <apex:pageblockTable value="{!account}" var="a" id="table2" columns="4" style="width:150%">
                <div id="edit:{!a.id}" style="width:35%;display:none;" >               
                 <apex:column headervalue=" First Name" colspan="1" rowspan="1" width="100" >                      
                     <apex:inputfield id="firstname" value="{!a.name}" />
                   </apex:column>                  
                    <apex:column headervalue=" Last Name" colspan="1" rowspan="1" width="100">                      
                    <apex:inputfield id="lastname" value="{!a.phone}" />
                   </apex:column>
                            <apex:column >   
                  <apex:commandButton id="savebutton" value="Save" onclick="HideShow('edit','{!a.id}','e');savedata('{!a.id}');"/>  
                  <apex:commandButton onclick="HideShow('edit','{!a.id}','e');" id="cancelButton" value="Cancel"/>              
               </apex:column>       
               </div>
              </apex:pageblockTable>           
      </div>
      </apex:pageBlock>  
</apex:outputPanel>
   <input id="xyz" type="hidden" onclick="ppppp();" />
    <apex:actionFunction id="saveaccount" name="savedata" action="{!doSave}" reRender="opnl"  />
      <apex:param name="accountsave" assignTo="{!propviewdata}" value=""/>
   </apex:form>
</apex:page>

 

======================================================================================

 

class =================================================================================

 

public class EditAccount
{
    public List<Account> acc;
   
    public void doSave()
    {  
        for(account ac : acc)
        {
           update ac;
        }
    }
    public List<Account> getAccount()  
    {
       return (List<Account>) acc;
    }//End getAccount
   
    public void setAccount(List<Account> Acc)
    {
     this.acc = Acc;
    } 
  
    public EditAccount()
    {
        acc = [select id,Name, Phone,BillingCity,CreatedDate from Account limit 1000];
    }//End Constructor

}

 

Warm Regards

Rajat

Hi All, I have created a list of all contacts in a vf page and an edit and save button beside each name in the list, Can someone please help me out with the class (WITHOUT STANDARD CONTROLLER) for edit and save, such that once i click EDIT, only that particular contact in the list should be editable, and once i click SAVE, only that contact should be updated. Thanks, Dave

Hi all,

 

i have the following piece of code which runs when i try to deactivate a user :

 

=================================TRIGGER=======================================================

trigger closeTargetProspect on User (after Update) {

public List<Targets__c> Target_list = new list<targets__c>();

for (User u : trigger.new) {

if(!u.isActive) {

Target_list=[select id,Target_Start_Date__c, Target_End_Date__c, Contact_Owner__c from Targets__c where ownerid = :u.id and Target_End_Date__c = null];

for(targets__c t : Target_list)
{
    t.Target_End_Date__c= date.today();
}
if(target_list.size()>0)
{
    update Target_List;
}
}

}

}

=======================================END====================================================

 

When i deactivate the user, i get an error message :

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger closeTargetProspect caused an unexpected exception, contact your administrator: closeTargetProspect: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a09900000022LPDAA2; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Targets__c, original object: User: []: Trigger.closeTargetProspect: line 17, column 1

 

I had read some articles on MIXED_DML_OPERATION on community, but i am unable to get how to change this code to make it work

 

a piece of code i had found was :

 

===============================================================================================

 

private static void myFunc()

{

     ///1st DML operation

 

     User usr = [Select id from User where Id = :UserInfo.getUserId()];

 

     System.RunAs(usr)

     {

        Test.startTest();

         myFunc2();

         Test.stopTest();

     }

 

 

}

 

@future

private static void myFunc2()

{

   ///2nd DML operation

}

 

============================================================================================

 

I am not sure how to implement the methods in this trigger or how to make a call from this trigger to a seperate class where this method belongs.

 

Could you please help me out with changing the code?

 

Thanks in Advance

Rajat.

Hi All,

 

I had deactivated a user, which i want to activate once again.

 

However, i am not ablr to find that user in "All Users List"

 

Could you please tell me the steps to re-activate the user

 

Thanks in Advance

Rajat

Hi All,

 

I am trying to achieve inline editing feature for a requirement.

 

I have a sample code as below :

 

<apex:page standardController="Contact">  
 <apex:form >  
 <apex:pageBlock mode="inlineEdit">  
     <apex:pageBlockButtons >  
     <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>  
     <apex:commandButton action="{!save}" id="saveButton" value="Save"/>  
     <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>  
     </apex:pageBlockButtons>  
 <apex:pageBlockSection >  
     <apex:outputField value="{!contact.lastname}">  
         <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"  
             hideOnEdit="editButton" event="ondblclick"  
             changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>  
     </apex:outputField>  
     <apex:outputField value="{!contact.accountId}"/>  
     <apex:outputField value="{!contact.phone}"/>  
 </apex:pageBlockSection>  
 </apex:pageBlock>  
 </apex:form>  
 </apex:page>

 

The only thing that i have a problem is that in order to change a contact i have to append the url everytime with a contact id.

 

That works only in case of one record.


I have a visual force page, which display lot of contact records in a pageblocksection. How would i pass the id for the record i am editing and saving to this, as i would have many records

 

Could you please help me out with this requirement

 

Thanks,

Rajat.

Hi All,

 

I have a requirement where an admin user can delete the columns from a pageblocktable on the ui, without changing the code.

 

The admin user should be able to do this from the user interface.

 

Could you please tell me if this is feasible and how ?

 

Thanks in advance

Hi,

 

I have few questions:

 

Is it possible to display the reports and dashboards in the visualforce page? If yes, can anybody provide me with some refernce.

 

Is it possible to mail the Reports and dashboards?  If yes, then who can be the reciepients. Is it only the salesforce users present in the org. or can we provide any email address?

 

How can we show reports and dashboards in a section of an objects page layout or in the related lists of the object?

 

Thanks.

Is there any possiblity to place a dashboard in to a vf page? if yes just post me the idea to implement.

 

 

Thank you..

 

 

Regards,

 

kiran

hi,

I have a requirement where i meed to build visualforce pages for a salesforce site where the users login and can see the reports and download and print also.

 

1.Is it possible to build a report on VF page since i dont see any examples in documentations.

 

2. THe users with salesforce license can login in into my site and view reports?

 

3.Can we expose reports to sites?

 

4. How can we display a report on VF page?

 

please help me on this issue.I am scratching my head i have never gone thru this kind if requirement,

 

cheers---

Hi,

 

My requirement is " I want to save a dashboard in PDF/PPT(power point) format. Pirioty as ppt format"

 

My approach is : I am developing a VF page where I will display the dashboard & then using renderAs attribute I will be able to save it as .pdf file as I am not having any idea on saving it as a .ppt file.

 

1. Is there any way that I can save dashboard as .ppt file?

 

 2.Is there any way that if I cant save the dashboard as .ppt then I can save it as .pdf somehow?

 

If any one has any idea/suggesion then please share with me.

 

Thanks,

Amit

Hi ,
I have made an Standard Controller page. In this Standard controller page i have used like this
Code:
<apex:page standardController="Contact" tabStyle="Contact" recordSetVar="allContacts" extensions="ContactMassUpdate" showHeader="true"> 

 
but this give error
Error is :
Code:
Save error: Unknown constructor 'ContactMassUpdate.ContactMassUpdate(ApexPages.StandardSetController controller)'

 
I think This error comes due to use recordSetVar and extensions together is there is any alternate solution of this or i am wrong at an any step
How can I do this. Can you plz help me