• deepak balur 19
  • NEWBIE
  • 170 Points
  • Member since 2016

  • Chatter
    Feed
  • 5
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 71
    Replies
Hi I have writter a trigger for updating child object(CTOpportunity__c) records if there is an update in opportunity(parent) record then the related field should update in the child record(CTOpportunity__c object). While saving the record, It's giving the following error (Update failed. First exception on row 0 with id a0dP0000000S6tRIAS; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Category: bad value for restricted picklist field: Phone, Electronics & Accessories: [Category__c]: Trigger.Intg_Opty_Update: line 29, column 1) here field Category__c is picklist . What might be the cause?. Thanks in Advance.

Trigger Code
trigger CTOpty_Update on Opportunity(after update) {
 
    set<Id> OptIds = new set<Id>();
    
    map<Id, Opportunity> mapOpty = new map<Id, Opportunity>();       
      
    List<CTOpportunity__c> lstIntgopt = new List<CTOpportunity__c>();  
    
    for(Opportunity Opt : Trigger.New) {
         OptIds.add(Opt.Id);
         mapOpty.put(Opt.Id, Opt);
         }        
     
    lstctopt = [SELECT Name, Amount__c, Total__c,Category__c,Commission__c,
                  Opportunity__c FROM CTOpportunity__c WHERE Opportunity__c IN: OptIds];
                   
    if(lstctopt.size() > 0) {
        for(CTOpportunity__c ctop : lstIntgopt) {
            ctop.Amount__c = mapOpty.get(ctop.Opportunity__c).Amount__c;
            ctop.Total__c  = mapOpty.get(ctop.Opportunity__c).Total__c;           
            ctop.Category__c = mapOpty.get(ctop.Opportunity__c).Category__c;            
            ctop.Commission__c = mapOpty.get(ctop.Opportunity__c).Commission__c;           
            }
        update lstctopt;
    }
}
Hello all,

I created a custom button on Case object and purpose of the button is to escalate the case. Here is the code and it works great.

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

var caseObj = new sforce.SObject("Case"); 
caseObj.id = '{!Case.Id}'; /* Need Id field to update Case */ 

if ({!Case.IsEscalated} == 0) 

caseObj.IsEscalated= 1; 
}; 


/* Change escalated field */ 

/* update method takes an array of Cases; init to 1 element - 'caseObj' */ 
var result = sforce.connection.update([caseObj]); 

if (result[0].success == 'false') { 
alert(result[0].errors.message); 

}

Now I want to use this custom button in visual force page and add that VF page on feed view, this is what I did with VF page:

<apex:page standardController="Case" extensions="CaseController" tabStyle="Case" >
  <apex:form >
  <apex:commandButton action="{!URLFOR($Action.Case.Escalate, Case.Id)}" value="Escalate"/>
  </apex:form>
</apex:page>

I added above VF page on feed view layout and it shows up the custom button as seen below

Escalate Button

but when I click the button, it doesn't execute the java scripts and shows the following windows after button click

Escalate After Click

Thanks in advance for help!

P
I have a VF page that gets  child records for a custom object master record and displays in an editable grid format.

However once I press "Save" i get the below error:
Error: There is no record to save

I'm guessing this is becasue the button triggers from the master object but the page controller uses the child records however if I switch the controller and page to be a related list the controller no longer works.

Controller:
public class EditAllButtonForTimeSheetController {

    public EditAllButtonForTimeSheetController(ApexPages.StandardController controller) {

    }

  public String TSRecordId        {get; set;}

  public List<Time_Sheet_Items__c> getTimeSheetRecords()
     {
    
       //Sets Time Shet id to variable
       TSRecordId = ApexPages.CurrentPage().getparameters().get('id');

        // this query needs a where clause, don't leave it unbounded
        List<Time_sheet_Items__C> TimeSheetRecords = 
         [SELECT Id,
            Time_Sheet__c,
            D_Type__c,
            D_Product_manager__c,
            D_Project__c,
            Day_Monday__c,
            Day_Tuesday__c,
            Day_Wednesday__c,
            Day_Thursday__c,
            Day_Friday__c,
            Day_Weekend__c
       FROM Time_Sheet_Items__c 
       WHERE Time_sheet__c = :TSRecordId  ];
    return TimeSheetRecords;
    }
}



VF Page:

<apex:page standardController="Time_Sheet__c"
         Extensions="EditAllButtonForTimeSheetController">
  <apex:form >
    <apex:pageBlock >
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save"
                            action="{!save}"/>
      </apex:pageBlockButtons>
      <apex:pageBlockTable value="{!TimeSheetRecords}"
                           var="TSi">
        <apex:column style="width:5%" value="{!TSi.D_Project__c}"/>
        <apex:column style="width:5%" value="{!TSi.D_Type__c}"/>
        <apex:column style="width:5%" value="{!TSi.D_Product_Manager__c}"/>
    <apex:column style="width:5%" headerValue="Monday">
          <apex:inputField value="{!TSi.Day_Monday__c}"/>
        </apex:column>
    <apex:column style="width:5%" headerValue="Tuesday">
          <apex:inputField value="{!TSi.Day_Tuesday__c}"/>
        </apex:column>
    <apex:column style="width:5%" headerValue="Wednesday">
          <apex:inputField value="{!TSi.Day_Wednesday__c}"/>
        </apex:column>
    <apex:column style="width:5%" headerValue="Thursday">
          <apex:inputField value="{!TSi.Day_Thursday__c}"/>
        </apex:column>
    <apex:column style="width:5%" headerValue="Friday">
          <apex:inputField value="{!TSi.Day_Friday__c}"/>
        </apex:column>
    <apex:column style="width:5%" headerValue="Weekend">
          <apex:inputField value="{!TSi.Day_Weekend__c}"/>
        </apex:column>
      </apex:pageBlockTable>     
    </apex:pageBlock>
  </apex:form>
</apex:page>

                

 
Setup a Flow with a visual force page that redirects a user to the salesforce home page, however, can anyone let me know how to redirect a user to another page within Salesforce1? Currently the user gets directed to the Salesforce.com page within a frame in SF1. 

here is my complete code: 
 
<apex:page standardController="RemodelerSurvey__c" standardStylesheets="false" showHeader="false" docType="html-5.0" >




    <html>
        <head>
            <style type="text/css" >
                <apex:stylesheet value="{!$Resource.CSSCode}" />

            </style>

        </head>

            <body>
                      
                     <apex:image url="{!$Resource.JHBRF_400px}"  style="max-width:90%" />

     <FlowContainer >
        <FlowTextArea>
                  <flow:interview name="Business_Review_Form_Survey" buttonLocation="bottom" finishLocation="{!URLFOR('/home/home.jsp')}"/>
        </FlowTextArea>
     </FlowContainer >

            </body>

    </html>

</apex:page>

 
Hello, 

I would like to have the option of deciding into what kind of Account I want to convert a Lead, I already have those 3 Account types as well as their record types assigned to Account itself. 
The tricky part for me now is having the option of picking one of these 3 accounts as choices once I decided converting a Lead. 
I'd be grateful for any kind of assistance. 
Keep getting the error unknown property: AccountController.DisplayAccount.operations_status__c

Have a page block as follows:
    <apex:pageBlockTable title="Account" value="{!Accntlist}" var="Accnts">
                
                      <apex:column headerValue="Id" value="{!Accnts.Id}" />
                    <apex:column headerValue="Name" value="{!Accnts.Name}" />
                       <apex:column headerValue="Status" value="{!Accnts.Operations_Status__c}" />
                       
            </apex:pageBlockTable>

Controller so far is at:

public class AccountController {
    
     public Static List<DisplayAccount> getAccntlist() {

         List <DisplayAccount> Accntlist = new List<DisplayAccount>();
         for (Account A : [SELECT Id, Name,Operations_Status__c  FROM Account]){
             Accntlist.add(new DisplayAccount(A));
         }
            return Accntlist;
     }
    
    public class DisplayAccount{
        private Account VAccnt;

        public DisplayAccount(Account A) {
            this.VAccnt = A;
        }

        public String ID {
            get { return VAccnt.Id; }
        }

        public String Name {

            get { return VAccnt.Name; }

        }
    
        public String Status {

            get { return VAccnt.Operations_Status__c; }

        }}//End of Class Display Account
    
 public PageReference addToCart() {
    return null;
   
}//End of AddtoCart

}//End of Class
I have a Map
Map<String, List<sObject>> r2I = new Map<String, List<sObject>>();

----code to populate the Map... The sobject belong to different objects like Lead, Account etc so the Map basically is a medley of different objects.

Now want to extract the List for bulk insert so doing the following
list<sObject> sObjInsertLists = new list<sObject>();
for (String objType : r2I.keySet()) {
  sObjInsertLists.add(r2I.get(objType);
}

insert sObjInsertLists;

I keep getting the error "Incompatible element type List for collection of Sobject...". Is there a way to solve this?
I am having issues to get the Classes loaded once Developer Console is launched. The Open window hangs on classes but as I scroll up and down thru other entities it loads those objects like Triggers, Pages etc. Anyone know the solution to this. I have changed browsers between Google and IE and still same behavior.
I am having issues to get the Classes loaded once Developer Console is launched. The Open window hangs on classes but as I scroll up and down thru other entities it loads those objects like Triggers, Pages etc. Anyone know the solution to this. I have changed browsers between Google and IE and still same behavior.
Hi, 

 I want to use a || (OR) operator condition inside the code But I get error Error: Compile Error: unexpected token: '||' at line ​

  
Please suggest me how to add with multiple add and or condition in the if statement
public PageReference  ApprovalpageAction(){
   if ( SPRProcheck > 0 &&
        P_SPR_Approver_Director <> NULL && 
        P_SPR_Approver_RVP <> NULL && 
        P_SPR_Approver_GVP <> NULL && 
        P_SPR_Approver_EVP <> NULL && 
        Olicheck > 0 && Athcheck > 0 &&
        UsrNFRcheck == 0 ) || ( UsrNFRcheck == 1)
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     }
   else if ( 
           SPRProcheck > 0 && 
           P_SPR_Approver_Director <> NULL && 
           P_SPR_Approver_RVP <> NULL && 
           P_SPR_Approver_GVP <> NULL && 
           P_SPR_Approver_EVP <> NULL && 
           Olicheck == 0 && 
           UsrNFRcheck == 0 )
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     } 
   else if ( SPRProcheck > 0 && 
             P_SPR_Approver_Director <> NULL && 
             P_SPR_Approver_RVP <> NULL && 
             P_SPR_Approver_GVP <> NULL && 
             P_SPR_Approver_EVP <> NULL && 
             UsrNFRcheck == 1 && OppNFRcheck == 1 && 
             P_DitiDiscountcheck == 100  )
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     }   
    return redirectpage();  
 }


Thanks

Sudhir

Hi everybody,

in our implementation we decided to have all information about the process of student recruiting in separate related lists.

So, for example, under the object Person Accout (the applicant) we have the following related lists:

- Admissions
- Enrollments

Admissions are all the records being created while the Admission process is taking place and also contain student application information.
Enrollments would have all records related to the Admissions but where you can see if the student has paid or not the course or academic programm he has now to pay.

Is it possible to make appear only all admission records, whose admission stage is in "Admission approved" in the Enrollments related list?.

Only admissions which were approved would appear in the related list for Enrollments. Is that possible?
Hi...

Any one can give the solution for the above scenario.

Thanks.....
Okay.  Over four days trying to solve this and I officially have no idea what I am doing...

Background:
New to SF (About two weeks) (I Appologize in Advance)
Professional Edition (Think this is a big reason why I can't get this done with my experience level)
Created a Custom Object Called DRF which has a Master-Detail relationship with the Opportunity Object.  
The Opportunity Object has a Lookup relationship with the custom DRF object (Not sure if I need this)
Have watched and completed the 2016 Visualforce Workbook (A few times now)

What I want to accomplish:
I would like for my sales staff to be able to click a detail button from within the Opportunity Object that launches a visualforce page.  This page would include fields to input customer's responses.  (I want a visualforce page so that I can include helpful discovery questions for the users to have infront of them as well as links to more detailed discovery questions for them to utilize.)  These responses will reside in the DRF object.  

I will also use this data to populate e-mail templates for the users to send to clients to recap their discussions.  (We are in a heavy technical industry that can really get into the weeds quickly so it is nice to have a written copy of everything for them to review).

The problem I keep running into is I can not get the Visualforce page "pull" the DRF fields when I have the controller set to Opportunity. I had given up on that working so I went to using the DRF as the controll. Now I can figure out how to get the Visualforce page to update the correct record.

Page 13 of the workbook says that I should just have to {!opportunity.RDF__c.ExampleField} but I can never get that to work.  I have also tried __r and many other various ways.  

I really appreciate any and all help the community can provide.  I am hiring 4 new associates but really want to have this new system up before they onboard so we can get them up and running sooner!  Thanks again.

Ugly Code from a Newbee...
<apex:page StandardController="DRF__c">
  <!-- Page Header -->
  <apex:sectionHeader title="Discovery" subtitle="Discovery and Red Flag Report" />
  <!-- Begin Form -->
  <apex:form >
    <apex:pageBlock title="Discovery" mode="edit">
      <!-- How to Use Text -->
      <apex:outputPanel styleClass="rules">
        Use this Report to help build your Discovery Letter Email as the information you add will autopopulate into the email template.<br /><br />
      </apex:outputPanel>
      <!-- Fields -->
      <apex:pageBlockSection columns="1" showHeader="true" title="Prospect's Challenge">
        <apex:inputField value="{!DRF__c.The_Challenge__c}" required="false" />
      </apex:pageBlockSection>
       <apex:pageBlockSection columns="1" showHeader="true" title="Current Situation">
        <apex:inputField value="{!DRF__c.Current_Solution__c}" required="false" />
        <apex:inputField value="{!DRF__c.Electrical_System__c}" required="false" />
        <apex:inputField value="{!DRF__c.Other_Options__c}" required="false" />
        <apex:inputField value="{!DRF__c.Requirements__c}" required="false" />
      </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" showHeader="true" title="Cost of Challenge">
        <apex:inputField value="{!DRF__c.Cost_of_Challenge__c}" required="false" />
      </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" showHeader="true" title="Next Steps">
        <apex:inputField value="{!DRF__c.Next_Steps__c}" required="false" />
      </apex:pageBlockSection>   
      <!-- Button Section -->
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Save" action="{!save}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
  </apex:form>
  <!-- CSS -->
  <style>

    .rules {
      color: black;
      font-size: 14px;
      font-family: Arial;      
      margin: 10px 0 10px 30px;
      float: left;
      width: 100%;
    }
  </style>
</apex:page>
I created an object A, which is the detail (child) in a master-detail relationship of two other objects, B and C. I want to create another master-detail relationship on object D, which is the detail (child) of object A. Thus, object A would be the child of B and C and the master of D. However, when I try to do that, object A does not show up in the picklist. Is this possible?

trigger SubscriptionCMRRRollup on Zuora__Subscription__c (after insert, after update, after delete)
{
    
    Set<Id> BillingAccId = new Set<Id>();
    List<Zuora__CustomerAccount__c> BillingAccList = new List<Zuora__CustomerAccount__c>();
    
    if(Trigger.isInsert){
        for(Zuora__Subscription__c s: Trigger.new)
            BillingAccId.add(s.Zuora__CustomerAccount__c);
    }
    if(Trigger.isUpdate || Trigger.isDelete){
        for(Zuora__Subscription__c s: Trigger.old)
            BillingAccId.add(s.Zuora__CustomerAccount__c);
    }
    Map<id,Zuora__CustomerAccount__c> BillingAccMap = new Map<id,Zuora__CustomerAccount__c>([select id, Today_s_MRR__c from Zuora__CustomerAccount__c where id IN :BillingAccId]);
    
    for(Zuora__CustomerAccount__c sub:[Select Id,Today_s_MRR__c,( Select Id,Zuora__MRR__c from Zuora__Subscriptions__r) from Zuora__CustomerAccount__c where Id IN :BillingAccId]){
        for(Zuora__Subscription__c z: sub.Zuora__Subscriptions__r){
            BillingAccMap.get(sub.Id).Today_s_MRR__c += z.Zuora__MRR__c;
            BillingAccList.add(BillingAccMap.get(sub.Id));
        }
    }
    update BillingAccList;
}
 
Hello Saleforce group. Need help setting up when closed lost to include both mandatory pick list and mandatory comments. Can this be done in Salesforce?
Hi,

I would like to modify my indicator that deal with leads. 
The idea is to create three differents possibilites for that indicator : hot, warna and cold.
Cold definition : no activities for more than 2 months
Warm definition : no activities between 2 weeks and 2 months
Hot definition : activities between 0 and 14 days

I'm really struggling with it, help would be appreciate ! :)

Regards
Hi everyone,

I'm trying to upload a file in the notes&attachment section of an account, but with no luck. The documentation is very obscure, and I can't even find with the workbench explorer a file that I've uploaded with the salesforce interface.

- What I can't find is where to POST the query :
/services/data/v20.0/sobjects/Account/{ID},
/services/data/v20.0/sobjects/Account/{ID}/Attachment,
/services/data/v20.0/sobjects/Account/Attachment{ID}
- what syntax shoud the JSON data have ? Where do I specify the recordId the file should be attached to ?
- how can I retrieve it later ?

does anyone know how to do this ?
Thanks
Hi I have writter a trigger for updating child object(CTOpportunity__c) records if there is an update in opportunity(parent) record then the related field should update in the child record(CTOpportunity__c object). While saving the record, It's giving the following error (Update failed. First exception on row 0 with id a0dP0000000S6tRIAS; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Category: bad value for restricted picklist field: Phone, Electronics & Accessories: [Category__c]: Trigger.Intg_Opty_Update: line 29, column 1) here field Category__c is picklist . What might be the cause?. Thanks in Advance.

Trigger Code
trigger CTOpty_Update on Opportunity(after update) {
 
    set<Id> OptIds = new set<Id>();
    
    map<Id, Opportunity> mapOpty = new map<Id, Opportunity>();       
      
    List<CTOpportunity__c> lstIntgopt = new List<CTOpportunity__c>();  
    
    for(Opportunity Opt : Trigger.New) {
         OptIds.add(Opt.Id);
         mapOpty.put(Opt.Id, Opt);
         }        
     
    lstctopt = [SELECT Name, Amount__c, Total__c,Category__c,Commission__c,
                  Opportunity__c FROM CTOpportunity__c WHERE Opportunity__c IN: OptIds];
                   
    if(lstctopt.size() > 0) {
        for(CTOpportunity__c ctop : lstIntgopt) {
            ctop.Amount__c = mapOpty.get(ctop.Opportunity__c).Amount__c;
            ctop.Total__c  = mapOpty.get(ctop.Opportunity__c).Total__c;           
            ctop.Category__c = mapOpty.get(ctop.Opportunity__c).Category__c;            
            ctop.Commission__c = mapOpty.get(ctop.Opportunity__c).Commission__c;           
            }
        update lstctopt;
    }
}
Hello, 

I am trying to add UPDATE functionality to a controller and am getting the error: DML requires SObject or SObject list type: List<String>

However my variable is set up like this: public List<String> campaigns {get;set;}

I am not sure how to achieve the proper syntax here, and was hoping that someone out there in developerland would be able to help me!

Here is my (broken) controller: 
 
public with sharing class QualOpController
{

public List <Opportunity> listOfOpty {get;set;}
public List<String> campaigns {get;set;}

public PageReference saveOp(){
    UPDATE campaigns;
    return null;
    }

 public String getName(){
        return 'QualOpController';
        }

public void load() 
{
  campaigns= new List<String>();
  listOfOpty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ]; 
  
  Set<String> campaignSet = new Set<String>();
  for (Opportunity j : listOfOpty)
      campaignSet.add(j.Vert_Med__c);
      
      for (String campaign : campaignSet) 
      {
            campaigns.add(campaign);
      }
      campaigns.sort();
    }
}

Thanks in advance!

John

 
Hi All,

I am having problems when I try to invoke a Flow with Apex. I'm having the next problem:

Constructor not defined: [Flow.Interview.Asociado_correo_secundario_al_EmailMessage].<Constructor>(Id)

This is the part of code:

  public void beforeInsert(SObject so) {
        Case cas = (Case)so;
        if(cas.Origin=='Email'){
            MainCaseAnalyzer mCA = new MainCaseAnalyzer();
            mCA.analyzeDescription(cas);  
            system.debug('CASO BEFORE INSERT: ' + cas); 
        }
        if(cas.Status=='Reasignado'){
            cas.CAS_CHK_CasoReasignado__c=true;
        }
        
        List<EmailMessage> emailMessageList = [SELECT id,parentId FROM EmailMessage WHERE parentId =: cas.id limit 1];
        Flow.Interview.Asociado_correo_secundario_al_EmailMessage flow = new        Flow.Interview.Asociado_correo_secundario_al_EmailMessage(emailMessageList[0].id);
        flow.start(); 
            
    }

Any idea how to do it?

Thanks in advance!
I have an issue here. I have an object O1 and a field F1. Field F1 is getting updated when an record is created in another object O2 by a trigger running on object O1.
Field F1 cannot be edited by inline.
There is are validtions rules on object O1.
I need when i create a record in object O2 all the validation rules in O1 should get by passed and field F1 should get updated.
But when an user does an inline edit on a record present in object O1 the validation rule should fire.

To achieve this i am making the custom setting to true and in the validation rule i am using like below - 
 
​( $Setup.ByPassvalidation__c.Bypassrules__c ) && (TODAY() > PRIORVALUE(CloseDate))

This is working fine when i am inserting record in object O2. But if a user does an inline edit in object O1 the validation rule is not wokring.

Can anyone tell how to make this work.
I have got questions, I have add a new user into a role.. standard salesforce user.
However he can see all other user accounts, activities and ability to edit/write  .. this can’t be right.
 
How can limit access to only his accounts and maybe in the future I can share some more account or change the permission.
 
I tried few different role and permission but isn’t working for me.. please guide me the right steps
Thank you
Hi experts,

I created a class to insert Account List record. The condition is allow duplicate Account List name, but the owner is different from the existing record. 

Example:

Exisiting record:
Account List Name: HO_Test
Owner: Marion Legacion

To be inserted record:
1. Account List Name: HO_Test
   Owner: Marion Legacion
Result: This record cannot be inserted since there is a duplicate both Account List Name and Owner.

2. Account List Name: HO_Test
Owner: Noiram Legacion
Result: A record will be created since Marion Legacion is different from Noiram Legacion.

Note: I created a Unique field to be updated by Workflow to populate the Account List Name and Owner (Formula: Account List Name & OwnerId)


Here is my code which is not working.
 
public with sharing class InsertAccountListRec_TEST_cls {
    
    List<User> usersIdList; 
	Set<Id> usersIdSet = new Set<Id>(); 
	Set<Id> AffFromAcctSet = new Set<Id>(); 
	Set<String> uniqueFieldSet = new Set<String>();
    List<Affiliation_vod__c> allAffParentRecs = new List<Affiliation_vod__c>();
    List<Account_List_vod__c> newAccListRecList = new List <Account_List_vod__c>();
    List<Account_List_vod__c> xAcctListRecs = new List <Account_List_vod__c>();
    List<Account_List_vod__c> InsertedAccList = new List <Account_List_vod__c>();
    
    public InsertAccountListRec_TEST_cls(){
        allAffParentRecs = new List<Affiliation_vod__c>([SELECT Id, OwnerId, From_Account_vod__c, From_Account_Value__c, To_Account_vod__c
                                                         FROM Affiliation_vod__c
                                                         WHERE (From_Account_vod__r.Id = '0011200001GNrb0AAD' AND Parent_vod__c = True) 
														 AND OwnerId IN: getActiveUsers()]);
        
        System.debug('Parent Affiliation Record Count '+ allAffParentRecs.size());
		
        for(Account_List_vod__c xAcctListRecs  : [Select OwnerId, Unique_Owner_Name__c FROM Account_List_vod__c 
                                                  WHERE Name = 'HO_RADY\'S CHILDREN\'S UCSD'
                                                  AND OwnerId IN: getActiveUsers()])
        {
            uniqueFieldSet.add(xAcctListRecs.Unique_Owner_Name__c);
        }
        
        for(Affiliation_vod__c allParentAffRecs: allAffParentRecs){
            if(!AffFromAcctSet.contains(allParentAffRecs.From_Account_vod__c)){
                Account_List_vod__c AccListRec = new Account_List_vod__c();    
                AccListRec.Name = 'HO_' + allParentAffRecs.From_Account_Value__c; 
                AccListRec.Icon_Name_vod__c = '0';	
                AccListRec.OwnerId = allParentAffRecs.OwnerId;
                AffFromAcctSet.add(allParentAffRecs.From_Account_vod__c);
                newAccListRecList.add(AccListRec);
            } 
        }
        for(Account_List_vod__c accList : newAccListRecList){
            if(!uniqueFieldSet.contains(accList.Name + accList.OwnerId)){
                InsertedAccList.add(accList);
            }
        }
        
        try{        
            insert InsertedAccList ;
            System.debug('New Account List Records: ' + InsertedAccList);
        }catch(DMLException e){
            System.debug('exeption catch ' + e.getMessage()); 
        }
    }//end of 1st block
    
    public Set<Id> getActiveUsers(){
        
        usersIdList = new List<User>([SELECT Id
                                      FROM User
                                      WHERE (Profile_Name_vod__c LIKE '%Eisai_Epilepsy%' 
                                             OR Profile_Name_vod__c LIKE '%Eisai_PrimaryCare%') 
                                      AND IsActive = TRUE]); 
        
        for(User users : usersIdList){
            usersIdSet.add(users.Id);  
        }
        return usersIdSet;
    }
}// End of Class

Unique_Owner_Name__c - is the unique field.

I queried all the Unique_Owner_Name__c field of all Account List record and I checked the unique field set to see if the (accList.Name + accList.OwnerId) is existing, if not then add the Account List record to a list and DML Insert

Please help

Thanks
Marion
 
Hello - 

I have a controller with a variable that is output as an array - and I would like to use UPDATE to give my users the ability to make in-line edits to records displayed an a VF page.  Is this at all possible? 

Here is my controller:
public with sharing class QualOpController
{

public List <Opportunity> Opty {get;set;}
public list<String> campaigns {get;set;}

public PageReference saveOp(){
    UPDATE Opty;
    return null;
    }

 public String getName(){
        return 'QualOpController';
        }

public void load() 
{
  campaigns= new List<String>();
  Opty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ]; 
  
  Set<String> campaignSet = new Set<String>();
  for (Opportunity j : Opty)
      campaignSet.add(j.Vert_Med__c);
      
      for (String campaign : campaignSet) 
      {
            campaigns.add(campaign);
      }
      campaigns.sort();
    }
}

I am trying to get this statement:  

 
public PageReference saveOp(){
    UPDATE Opty;
    return null;
    }

 public String getName(){
        return 'QualOpController';
        }

to update these records: 
 
campaigns= new List<String>();
  Opty = [Select id, name, CreatedDate, StageName, Vert_Med__c, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE Pipeline_Oppty__c = TRUE ];

But the changes just won't save. 

Is there anything I can do differently to make this work? 

Thanks, 

John
Hi,
I have a visualforce component, in which I bind several attributes of an object.
In the component controller I have a method to upsert the modified record.
But my controller does not get the changed values, it always upsert my record with the old values. ( I dont get any exceptions)
Please kindly advise what I'm missing. Thanks.

My Component
<apex:component controller="RevenueComponent_Controller" allowDML="true">
   <apex:attribute name="revenueRecord" description="Revenue Record."
                    type="Revenue__c" required="true" assignTo="{!revenue}"/>
   <apex:form >
        <apex:pageBlock mode="mainDetail" title="" id="revenueDetail">           
                         
            <apex:pageBlockButtons location="Top" >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
                <apex:commandButton action="{!saveRevenue}" id="saveButton" value="Save Revenue" reRender="recordDetails"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
            </apex:pageBlockButtons>
            
            
            <apex:pageBlockSection id="recordDetails" title="" columns="2">       
                <apex:inputField value="{!revenue.Year__c}"/>
                <apex:inputField value="{!revenue.Month__c}"/>         
                <apex:inputField value="{!revenue.Forecast_Amount__c}"/>
                <apex:inputField value="{!revenue.Actual_Amount__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:component>

Component Controller
public class RevenueComponent_Controller {
    public Revenue__c revenue;    
    
    public Revenue__c getRevenue(){
        return revenue;
    }
    
    public void setRevenue(Revenue__c r){
        revenue = r;        
    }
    
    public void saveRevenue(){
        System.debug('Revenue ::: ' + revenue);        
        upsert revenue;
    }
    
    public void edit(){
        
    }
}

My VF page in which the component is located.
...
        <apex:pageBlockSection title="Revenue List For FY 2016" columns="1">
            <apex:repeat value="{!projectRevenues}" var="revenue">
            
            <c:Revenue revenueRecord="{!revenue}" />
            
            </apex:repeat>
        </apex:pageBlockSection>

...