• Vijaya Kumar Reganti
  • NEWBIE
  • 350 Points
  • Member since 2012

  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 16
    Questions
  • 61
    Replies
Hi!..I have a requirement. Before submitting a record into an approval process, I need to validate some information in others records..if the validation fails, I need to send a warning to the user…if it’s ok, the approval process is fired.
Any idea in order to achieve the requirement? I’m lost here, any kind of help is welcome.
Hi.
I have two custom objects Our_va__c and Cancellation__c. cancellation has Lookup to Our VA.

I need to fetch all cancellation records for the purticular Our va. I have written query like..
 
///***** Cosider All our_va__c ids are in Ovaids

List<our__va__c> ova= new list<our_va__c>();

ova=[select id,name, (select name from cancellation__r) from our_va__c where id IN : Ovaids]

I got the error didn't Understand the relationship...

Anyone help plz??
I know this question has been asked before. The question was never satisfactorily answered. 

I have changed the configuration of the Case Owner field in the Case layout to read-only, but the "change" is still active.

Is there a way to override this behaviour to remove this link, or by making this Case Owner really read-only?

or  as workaround I have created a new formula field : Owner:User.FirstName + " " +  Owner:User.LastName. However this only works (shows the owner) after the case is saved. Is there a way to make the Owner apear when the Case is created just like the real Owner field?

maybe have two layouts 1) one with the owner field when the case is created, 2) in edit mode, the case owner is replaced with my custom field.

or, programmically swich fields with a trigger when the case is saved.
Hi All,

    I have an objecte created with custom field Gender (type is pick list and contains 2 values Male and Female). Now I want to show this values on my visualforce page.
   Can anyone please tell me how I can do that ?

   When I searched on internet i got this piece of code :
<apex:selectList value="{!countries}" multiselect="true">
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><p/>
but I only know my object name and field name. Not sure how to use above.
For example suppose my object name is 'Information' and picklist custom field is 'Gender' How I can write this in above snippest.

Also after that I want to send selected value to apex controller.

Thanks in advance.


Best Regards,
Abhishek 

   

 The following SOQL executes successfully in the Force.com developer console, but not through the API using the Partner WSDL.   I am logging in as the same user to the API as I use for the developer console (same user, System Administrator profile).


SELECT OpportunityId, Id, PricebookEntryId, Product2.Name, ProductCode, Quantity, UnitPrice, Description, LastModifiedDate, IsDeleted FROM OpportunityLineItem LIMIT 5

I'm using the SOAP 31.0 api and getting the following error:

First I got an error on the Product2.Name, removed that from the SOQL and got an error on the ProductCode:

No such column 'ProductCode' on entity 'OpportunityLineItem'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

The API worked fine with the same SOQL accessing test.salesforce.com, but not login.salesforce.com.

I looked in to field level security, but I am using the same user account/system admin profile for both developer console and api. 

Appreciate any guidance you can provide.
Where can I get a list of all the methods for APEX  Messaging.SingleEmailMessage

Hi Friends,

 

I have created preparing the XML content in my Apex class and getting into a string and used "contentType" along with <apex:outputText> on the VF page to download it as an .xml file.It is working fine.

 

But what I want to do is, I need to create multiple XML files ,need to download into different files and then attached to to the attachments to a particular record.

 

Please suggest a way to do this. 

Hi Friends,

 

I have a requirement to put a custom button on the record definition page, when clicked, it should call an Apex class which generates an XML file based on the valus from the record.

 

Can you please suggest a way for achieveing this.

Hi Friends,

 

I am trying to do the following query but I am not able to save it and I am getting an error like System.Today() Is not available.

 

Stats__c[] Stats = [Select Id,Mode_of_Travel__c,School__c FROM Stats__c Where CreatedDate = System.Today() ];

 

Please help me to figure out the problem here.

 

Hi Friends,

 

I have Term__c as parent and Stats__c as child .

 

On the Term__c object I have Allow_Update_for_Past_Dates__c and End_Date__c fields.

 

My requirement is to allow the user to save the Stats__c record whent the Allow_Update_for_Past_Dates__c checkbox is checked or End_Date__c is in future. If these two coditions failed, then the stats record should not be saved.

 

Please help me to achieve this.

 

Thanks,

 

Vijay

Hi Friends,

 

I have requirement to allow the user to save the contact  record only when the Date__c  field in Account record is in future.

 

How to achieve this.Pls help.

 

Thanks,

 

Vijay 

Hi Friends,

 

I have a requirement to write the following Trigger.

 

Trigger MyTrg on contact (Before insert){

 

            for (contact c : Trigger.new){

 

               list<account> lst = [Select Id,Name From Account];

   }

          

}

 

But as the SOQL query is inside the FOR loop,it hits the Governor Limit.

 

How to avoid it in a meaningful way.

 

Thanks in Advance,

 

Vijay

Hi Friends,

 

I have a query as follows.

 

[SELECT id,Name,Body_of_topic__c,Subject_Line__c FROM Topics__c Order By Sort_Order__c]

 


where  Sort_Order__c field is a number field. So please tell me the result of this query and the importance of the Order By clause. What happens if Sort_Order__c is 1,2,3  etc.

 

Thanks,

 

Vijay

Hi Friends,

 

I have a requirement to do the following query.

 

[Select Opportunity.Territory from OpportunityLineItem]  

 

 


When I have tried this, I am getting an error like there is no entity "Territory"  on "Opportunity" Object.

 

Please help in this regard.

 

Thanks,

 

Vijay

Hi Friends,

 

I have a requirement to query on the standard object "Opportunity_Product".I don't know the object name to query.

 

Please help me.

 

Thanks,

 

Vijay

Hi All,

 

I have a code to send the email.Upon sending the email,I am creating an activity with that mail.

 

But when I am saving the body of the email into Description field of the Activity, all the HTML tags are appearing.

 

Like if there are multiple lines present in the body of the mail, then it displays multiple <br></br> tags for each line.

 

Please help me resolve this issue.

 

Thanks,

 

vijay

Hi All,

 

I have created a force.com site.Now as the users try to login to this site, there are getting this SSL Certifiacte error.

 

If we click on "Procede Anyway", then the user will be allowed into the site.

 

How should I resolve this for the entire Organisatiion users.

 

Thanks,

Vijay

Hi All,

 

I have created a sharing rule for certain criteria.

 

How can edit it and change the previous criteria???

 

"share with" is not in editable mode.So how can I change this???

 

Thanks,

Vijay

 

 

Hi All,

 

I have a picklist and a text field.for a particular picklist value I don't want to allow the input(number also) in the text field and it has to show an error message.For the other values it has to allow the input in the text field. 

 

I have written the following code for this 

 

if(objqirs.Alert_Type__c == 'NPI Launch Impact' && objqirs.Last_Approved_Program_Milestone__c == null){
NPIError = true;
return null;
}
else{

}

 

this restricts only the text values.Please help me to restrict the numbers also in Last_Approved_Program_Milestone__c field.

 

If I give number in that field, my validation will not work and the record will be saved.this should not happen.

 

Thanks,

Vijay

I have a VF page with <apex:messages/>,a field which has a validation rule and  ApexPages.AddMessage() method in the class.

The validation written for field is to display an error message at the field.but it is displaying the error message at the top of the page also.

So How can I remove the Top message with out removing the <apex:messages/> tag.

How do I pass the record Id to the URL of the VF page from the class??

 

How can I get the record Id from the URL of the VF page into the class??

 

when I try to click on the Login button which I ahve created with out giving any credentials,This is the exception  I got.So please help  me to handle this error.

 

Class :

 

public with sharing class logincls {

Public boolean show {get;set;}
Public string username {get;set;}
public string password {get;set;}

Public pagereference login(){

    Registrations__c reg = [Select id,Password__c from Registrations__c where user_name__c =: username];
   
    if(reg.password__c == password){
    
        pagereference ref = new pagereference('/apex/products');
        return ref;
    }
    
    else{
    
        show = true;
        return null;
    }
  }
 
     public Logincls(){
    
        show = false;
 
    }
    
  }

 

VF Page:

 

<apex:page sidebar="false" controller="logincls">
     <apex:form >
     <apex:pagemessages ></apex:pagemessages>
         <apex:outputPanel >
         <table align="center">
             <tr>
                 <td>
                 </td>
                 <td><apex:outputLabel rendered="{!show}" style="color:red;fint-size:20">**Warning: Invalid Credentials</apex:outputlabel>
                 </td>
             </tr>    
             <tr>
                 <td>
                 <apex:outputLabel >User Name</apex:outputLabel>
                 </td>
                 <td>
                 <apex:inputText value="{!username}"/>
                 </td>
             </tr>
             <tr>
                 <td>
                     <apex:outputLabel >Password</apex:outputLabel>
                 </td>
                 <td>
                     <apex:inputsecret value="{!password}"/>
                 </td>
             </tr>
             <tr >
                 <td align="center" colspan="2">    
                     <apex:commandButton value="Login" action="{!login}"/>
                 </td>
             </tr>
              <tr>
                 <td>
                 </td>
             </tr>
              <tr>
                 <td>
                 </td>
             </tr>
              <tr>
                 <td>
                 </td>
             </tr>
             <tr >
                 <td align="center" colspan="2">
                     <apex:commandLink value="New User Registration" action="/apex/register"/>  &nbsp;&nbsp; &nbsp;
                     <apex:commandLink value="Forgot Password ??" action="/apex/forgot"/>      
                 </td>
             </tr>
            
             </table>    
         </apex:outputPanel>
     </apex:form>
</apex:page>

trigger AssignCloseOppTeamMember on OpportunityTeamMember (after insert) {
List<Opportunity> OpportunityList = new List<Opportunity>();
Map<Id, Id> OppIdOppMemberIdMap = new Map<Id, Id>();

for(OpportunityTeamMember OpportunityTeamMemberObj: Trigger.New){
    if(OpportunityTeamMemberObj.TeamMemberRole =='Portfolio Developer')
    
        OppIdOppMemberIdMap.put(OpportunityTeamMemberObj.OpportunityId , OpportunityTeamMemberObj.Id);
}

for(Opportunity opportunityObj : [Select Id, LocalPortfolioDeveloper__c from Opportunity where Id IN: OppIdOppMemberIdMap.keyset()]){
    if(OppIdOppMemberIdMap.Containskey(opportunityObj.Id)){
        opportunityObj.LocalPortfolioDeveloper__c= OppIdOppMemberIdMap.get(opportunityObj.Id).User.Id;
        OpportunityList.add(opportunityObj);
        }
    }
update OpportunityList;

}
getting error - Compile Error: Initial term of field expression must be a concrete SObject: Id at line 13 column 95
This is my test class: 

@IsTest(SeeAllData=true) 
public with sharing class TestInsertDefaultLineItems {
    static testMethod void validateTrigger() {
       Account acc= new Account(Name = 'testAcc', Description='testdesc');
       insert acc;

        //Case record in Test method. 
        Contact conObj = new Contact();
        conObj.lastname = 'testcon';
        conObj.AccountId = acc.id;
        insert conObj;
 
        Opportunity opp1 = new Opportunity (AccountId = acc.Id, Name = 'testOpp', CloseDate = System.today());
            insert opp1;
        
       /* PricebookEntry priceBookEntryNew = new PricebookEntry ();
        Product2 product = new Product2 ();
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook', Description='test');
        insert pb2;      
       List pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true ];*/
        
     PricebookEntry priceBookEntryNew = new PricebookEntry();
        Product2 product = new Product2(); 
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook',Description = 'test');
        insert pb2;
        List <PriceBook2> pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true];
        PriceBook2 pricebooktest = new PriceBook2 ();
        if (pricebookList !=null && pricebookList.size()>0)
            pricebooktest = pricebookList.get(0);
        product.name = 'Test';
        insert product;
        
        priceBookEntryNew.Product2Id = product.Id;
        priceBookEntryNew.PriceBook2Id = pricebooktest.Id;
        priceBookEntryNew.UnitPrice = 20.00;
        priceBookEntryNew.UseStandardPrice = false;
        priceBookEntryNew.isactive = true; 
        insert priceBookEntryNew;

        OpportunityLineItem oli = new OpportunityLineItem
            (OpportunityId = opp1.Id,
             PricebookEntryId = priceBookEntryNew.Id,
             Quantity = 1,
             UnitPrice = priceBookEntryNew.UnitPrice,
             
             ServiceDate = System.today()
            );
        insert oli;
    }
}
How do I allow all users to use this apex? It's currently restricted to my community users.

public without sharing class EventActions 
{
  public static void SetAccountUsedSessions(List<Event> events)
  {
    Set<Id> accountIds = new Set<Id>();
    for(Event event : events)
    {
      if(event.AccountId!=null && !accountIds.contains(event.AccountId)) accountIds.add(event.AccountId);
    }
    if(accountIds!=null&&accountIds.size()>0)
    {
      Map<Id, Account> accountsToUpdate = new Map<Id, Account>();
      AggregateResult[] countResults = [SELECT AccountId, count(Id)cnt FROM Event WHERE AccountId IN :accountIds  AND IsRecurrence=false AND Subject LIKE 'PT%' AND ActivityDate <= TODAY AND EVENT_STATUS1__C <> 'Cancelled WITH 24hr Notice' GROUP BY AccountId];
      if(countResults!=null&&countResults.size()>0)
      {
        for (AggregateResult ar : countResults)  {
          String accountId = String.ValueOf(ar.get('AccountId'));
          String usedSessions = String.ValueOf(ar.get('cnt'));
          if(accountId!=null&&accountId!=''&&usedSessions!=null&&usedSessions!='')
          {
            Account account = new Account(Id=accountId);
            account.Used_Sessions__c = integer.valueOf(usedSessions);
            accountsToUpdate.put(account.Id, account);
          }
        }    
      }
      for(Id accountId : accountIds)
      {
        if(!accountsToUpdate.containsKey(accountId))
        {
          Account account = new Account(Id=accountId);
          account.Used_Sessions__c = 0;
          accountsToUpdate.put(accountId, account);
        }
      }
      if(accountsToUpdate!=null&&accountsToUpdate.values().size()>0) update accountsToUpdate.values();
    }
  }
  
  public static testMethod void Test()
  {
    List<Event> events = [SELECT Id, WhatId, AccountId FROM Event WHERE AccountId<>null 
      AND IsRecurrence=true AND Subject LIKE 'PT%' LIMIT 10];
    Event events2 = [SELECT Id, WhatId, AccountId FROM Event WHERE AccountId<>null 
      AND IsRecurrence=false AND EndDateTime > :system.today().toStartOfWeek() LIMIT 1];
    
    Profile sysAdminProfile = [SELECT Id FROM Profile WHERE Name='Corporate' LIMIT 1];
    
    User u = [select Id from User where IsActive = true and UserType = 'Standard' 
      and ProfileId != :sysAdminProfile.Id limit 1];
    System.runAs(u) {
    
      SetAccountUsedSessions(events); 
      update events2;
      delete events2;
    }
    
  }
}
Unable to Pass Control Access to the Org in Data Security - I have meet all the requriement to pass the module but keep getting "The user's profile was not set to System Administrator". Below is what my user look it:
Name:  guestadmin guestadmin                    Role 
Alias:    ggues                                                User License:  Salesforce
Email:   guestadmin@tarjani.com                  Profile:   System Administrator
Username:  guestadmin@tarjani.com            Active: (Unchecked)
Nickname:   guestadmin77 
Link to Trailhead: https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/data_security/units/data_security_org
 
How to allow Community users to edit their related contact fields, but no one elses?
Hi!..I have a requirement. Before submitting a record into an approval process, I need to validate some information in others records..if the validation fails, I need to send a warning to the user…if it’s ok, the approval process is fired.
Any idea in order to achieve the requirement? I’m lost here, any kind of help is welcome.
More specifically, I want to create various individual SELECT queries in which I retrieve the first 1000 results of the object, than the next 1000 and so on.
Example:
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1 AND 1000;
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1001 AND 2000;
(...)

The thing is, the column "rowIndex" (or an equivelent one) does not exist in the object (column "Id" does not qualify). 

So, how can I retrieve only 1000 results each time of the query: "SELECT Id, Name FROM Account"?

Thank you.
Hi there,

For the last days I have been struggeling with Apex Triggers, I need to roll up a currency field from the (standard) 'Account' object to the custom 'CustomerGroups__c' object. I'd prefer avoiding Apex, but Sales Force does not allow me to make a parent for the Account object.

From the child 'Account', I'd like to roll up the currency field "Customer_OLB__c" and summarize those amounts in the parents object 'CustomerGroups__c' field 'Customer_Group_OLB__c'.

Adjusting one of the previously provided examples has lead me to to following code, where I get an problem in line 2: "unexpected token: ':' "  
 
trigger UpdateAccount on Account (after insert, after update, after delete, after undelete) {
  Map<Id,CustomerGroups__c> updateCustomerGroups = new Map<Id,CustomerGroups__c>;
  Set<Id> updateCustomerGroupsIds = new Map<Id,CustomerGroups__c>();
    if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)
        for (Account account:Trigger.new)
        updateCustomerGroupsIds.add(account.CustomerGroups__c_Name);
    if(Trigger.isUpdate || Trigger.isDelete)
        for (Account account:Trigger.old) 
        updateCustomerGroupsIds.add(account.CustomerGroups__c_Name);
    updateCustomerGroupsIds.remove(null);
    
    for(Id CustomerGroupsId:updateCustomerGroupsIds)
        updateCustomerGroupsIds.put (CustomerGroupsId,new CustomerGroups (id=CustomerGroupsId,Accounts_Count=0);
        for Account account:[select id,CustomerGroups__c_Name from account where CustomerGroups__c_Name in :updateCustomerGroupsIds])
        
        updateCustomerGroups.get (account.CustomerGroups__c_Name).Accounts_Count++;
    Database.update(updateCustomerGroups.values());
)       
}
Any help would be much appreciated!

Kind regards,

Thijs
 
Dear All,

I was trying to write test class for my trigger, but it it giving me error like below
'FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, restrictCase: execution of BeforeInsert' , 'FATAL_ERROR caused by: System.NullPointerException: Attempt to de-reference a null object'

heres my trigger
trigger restrictCase on Case(before insert)
{
MaxCase__c mxx = MaxCase__c.getInstance('MaxValue');    
Integer mvv = Integer.valueOf(mxx.Max__c);
    system.debug('int value' + mvv);

Set<Id> userIds = new Set<Id>();

    
for (case cc : Trigger.new)  
{
userIds.add(cc.ownerId);
} 
 
List<User> userss = [Select Id, Name from User where Id in :userIds];  
Map<Id, Integer> userCases = new Map<Id,Integer>(); 
    
for (user u : userss)
{
 integer countCase = [Select count() from Case where ownerId=:u.Id AND createdDate = This_Month];
 userCases.put(u.id, countCase); 
 system.Debug('user and case' + u.Name + ' . ' + countcase);
}
  
for (case c : trigger.new)    
{

Integer countc = userCases.get(c.OwnerId);    
system.debug('current user case count' + countc);    
    if (countc > mvv)
    {
        c.addError('Too many cases created this month for user' + c.owner.Name + '(' + c.OwnerId + ')' + ':' + mvv);
    }
    
}   
    
    
    
}

and heres the test class I've written
 
@isTest

public class testRestrictCase {

 static testMethod void caseCreation1 ()
 {
          MaxCase__c maxi = new MaxCase__c();
     maxi.Name = 'newMax';
     maxi.Max__c = 80;
     insert maxi;
     
     system.debug('maxi custom setting' + maxi.Name);
     Integer maxiInt = Integer.valueOf(maxi.Max__c);
      system.debug('max value' + maxiInt);
     
     
  Account acct = new Account(Name='anamika');   
  insert acct;
     system.debug('account inserted' + acct.name);
 Contact con = new Contact(FirstName='aa', LastName='bb', AccountId=acct.Id, email='abc@g.com');
  insert con;
     system.debug('contact inserted' + con.name);

 List<Case> casess = new List<Case>();
     for(integer i = 0; i<maxiInt ; i++)
     {
    Case TestC = new Case(Subject='Test Controller Acct Case'+ i, accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');
     casess.add(Testc); 
system.debug('testC .i.' + TestC.Subject);
 }
   insert casess;
     system.debug('cases size' + casess.size());
     
     Case TestC1 = new Case(Subject='Test Controller Acct Case new', accountId=acct.id, status='New', origin ='Email', contactId=con.id, priority='Medium', type='Mechanical', reason='Installation');

     try{
         insert TestC1;
     }
 catch(DMLException ex)
 {
   system.debug('max cases inserted');  
 }
 
 }
}

​Please help me finding the issue.

Thanks a lot in advance.
I want to transfer some of the field data from Contract to Service TimeCard (Custom object) field.

The same field in both the object. Once the contract is created and under that when the service timecard record is generated the (Daily rate and Daily rate offset) data will automatically transfer from Contract to my custom object field.

I had applied the below code.


trigger servicecontract on Contract (after insert) 
{
    
 Set<Id> Ids= new Set<Id>();
    for (Contract member : Trigger.new)
    {
       Ids.add(member.Id);       
    }

 List <Contract> memberList = new List <Contract> ([Select Id, Daily_Rate__c, Daily_Rate_Offsite__c from Contract where Id in :Ids]);    

    for(Contract cont : memberList)

    {
  
       SFDC_Service_Timecard__c member = new SFDC_Service_Timecard__c();
    
        member.Daily_Rate__c = cont.Daily_Rate__c;
        member.Offsite_Daily_Rate__c = cont.Daily_Rate_Offsite__c;
       insert member;
    }
 }
Hi.
I have two custom objects Our_va__c and Cancellation__c. cancellation has Lookup to Our VA.

I need to fetch all cancellation records for the purticular Our va. I have written query like..
 
///***** Cosider All our_va__c ids are in Ovaids

List<our__va__c> ova= new list<our_va__c>();

ova=[select id,name, (select name from cancellation__r) from our_va__c where id IN : Ovaids]

I got the error didn't Understand the relationship...

Anyone help plz??
I know this question has been asked before. The question was never satisfactorily answered. 

I have changed the configuration of the Case Owner field in the Case layout to read-only, but the "change" is still active.

Is there a way to override this behaviour to remove this link, or by making this Case Owner really read-only?

or  as workaround I have created a new formula field : Owner:User.FirstName + " " +  Owner:User.LastName. However this only works (shows the owner) after the case is saved. Is there a way to make the Owner apear when the Case is created just like the real Owner field?

maybe have two layouts 1) one with the owner field when the case is created, 2) in edit mode, the case owner is replaced with my custom field.

or, programmically swich fields with a trigger when the case is saved.
Is there a time zone setting that can be set once and will automatically be adjusted when the time changes from Daylight to Standard time? All timestamps were behind by an hour after this past weekend. I changed default settings form Central Standard Time to Central Daylight Time. I would like it to be automatically adjusted to accomodate the change. Kind of like you don't have change your phone clock, it just happens!

Any ideas?
  • March 11, 2015
  • Like
  • 1
All,
I need to make my sales summary code more efficient. Once we hit 9,000 trades on a single Account, the system hits the CPU Limit governor limit, even in a batch job. Anybody have any ideas on the code below? Perhaps moving each calculation in the For loop under each  corresponding map? I'm not sure the best way to change this code, but any help would be greatly appreciated.

Debug log shows errors at random at lines 73, 79, or 92 in the Class and every time on line 4 in the trigger.
CPU Time varies on the number of trades inserted at a time, but even at 1 trade I can get up to 25000 out of 10000 (more than double).

Class:
public class Account_RollupTrades {
    public Static Account_Setting__c setting = Account_Setting__c.getInstance();
    public Static boolean inprog = false;

    public static void execute (Set<Id> accountIds, List<Account> accountsList) {
        Map<Id, Account> accounts = new Map<Id, Account> (AccountsList);
        system.debug ('execute');
        if(setting.Disable_RollupTrades__c != true) {
            //Map<Id, Account> accounts = new Map<Id, Account>();
            for(Id accountId:accountIds) {
                system.debug(accountid);
                accounts.put(accountId,
                   new Account(
                       Id=accountId,
                       /**YTD_NIOR_I_Sales__c = 0,         YTD_NIOR_I_Shares__c = 0,         QTD_NIOR_I_Sales__c = 0,         QTD_NIOR_I_Shares__c = 0,
                       MTD_NIOR_I_Sales__c = 0,         MTD_NIOR_I_Shares__c = 0,         PY_NIOR_I_Sales__c = 0,          PY_NIOR_I_Shares__c = 0,
                       Total_NIOR_I_Sales__c = 0,       Total_NIOR_I_Shares__c = 0,       YTD_NS_Income_Sales__c = 0,      YTD_NS_Income_Shares__c = 0,
                       QTD_NS_Income_Sales__c = 0,      QTD_NS_Income_Shares__c = 0,      MTD_NS_Income_Sales__c = 0,      MTD_NS_Income_Shares__c = 0,
                       PY_NS_Income_Sales__c = 0,       PY_NS_Income_Shares__c = 0,       Total_NS_Income_Sales__c = 0,    Total_NS_Income_Shares__c = 0,**/
                       Total_NS_HI_Sales__c = 0,       Total_NS_HI_Shares__c = 0,       YTD_NS_HI_Sales__c = 0,         YTD_NS_HI_Shares__c = 0,
                       QTD_NS_HI_Sales__c = 0,         QTD_NS_HI_Shares__c = 0,         MTD_NS_HI_Sales__c = 0,         MTD_NS_HI_Shares__c = 0,
                       PY_NS_HI_Sales__c = 0,          PY_NS_HI_Shares__c = 0,          Total_NS_Income_II_Sales__c = 0, Total_NS_Income_II_Shares__c = 0,
                       YTD_NS_Income_II_Sales__c = 0,   YTD_NS_Income_II_Shares__c = 0,   QTD_NS_Income_II_Sales__c = 0,   QTD_NS_Income_II_Shares__c = 0,
                       MTD_NS_Income_II_Sales__c = 0,   MTD_NS_Income_II_Shares__c = 0,   PY_NS_Income_II_Sales__c = 0,    PY_NS_Income_II_Shares__c = 0,
                       Rollup_Trades__c = DateTime.now()
                   )
                            );
            }
            Map<String, SObjectField[]>
                ytd = new map<string, sobjectfield[]> {
                    //'3910' => new sobjectfield[] { account.YTD_NIOR_I_Sales__c , account.YTD_NIOR_I_Shares__c},
                    //'3911' => new sobjectfield[] { account.YTD_NS_Income_Sales__c , account.YTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.YTD_NS_HI_Sales__c , account.YTD_NS_HI_Shares__c },
                    '3915' => new sobjectfield[] { account.YTD_NS_Income_II_Sales__c , account.YTD_NS_Income_II_Shares__c }    
                },
                qtd = new map<string, sobjectfield[]> {
                    //'3910' => new sobjectfield[] { account.QTD_NIOR_I_Sales__c , account.QTD_NIOR_I_Shares__c},
                    //'3911' => new sobjectfield[] { account.QTD_NS_Income_Sales__c , account.QTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.QTD_NS_HI_Sales__c , account.QTD_NS_HI_Shares__c },
                    '3915' => new sobjectfield[] { account.QTD_NS_Income_II_Sales__c , account.QTD_NS_Income_II_Shares__c }
                },
                mtd = new map<string, sobjectfield[]> {
                    //'3910' => new sobjectfield[] { account.MTD_NIOR_I_Sales__c , account.MTD_NIOR_I_Shares__c},
                    //'3911' => new sobjectfield[] { account.MTD_NS_Income_Sales__c , account.MTD_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.MTD_NS_HI_Sales__c , account.MTD_NS_HI_Shares__c },
                    '3915' => new sobjectfield[] { account.MTD_NS_Income_II_Sales__c , account.MTD_NS_Income_II_Shares__c }
                },
                py = new map<string, sobjectfield[]> {
                    //'3910' => new sobjectfield[] { account.PY_NIOR_I_Sales__c , account.PY_NIOR_I_Shares__c},
                    //'3911' => new sobjectfield[] { account.PY_NS_Income_Sales__c , account.PY_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.PY_NS_HI_Sales__c , account.PY_NS_HI_Shares__c },
                    '3915' => new sobjectfield[] { account.PY_NS_Income_II_Sales__c , account.PY_NS_Income_II_Shares__c }
                },
                total = new map<string, sobjectfield[]> {
                    //'3910' => new sobjectfield[] { account.Total_NIOR_I_Sales__c , account.Total_NIOR_I_Shares__c},
                    //'3911' => new sobjectfield[] { account.Total_NS_Income_Sales__c , account.Total_NS_Income_Shares__c },
                    '3912' => new sobjectfield[] { account.Total_NS_HI_Sales__c , account.Total_NS_HI_Shares__c },
                    '3915' => new sobjectfield[] { account.Total_NS_Income_II_Sales__c , account.Total_NS_Income_II_Shares__c }
                };
    
    // We make the select in a "for" so instead of selecting to many records at once hitting the heap size limit the for it will take only 200 records to work with at each iteration.
    for(Trades__c[] tradesList : [select Dollar_Amount_of_the_transaction__c, Fund_Number__c, Number_of_Shares_of_the_transaction__c, Resolved_Firm_Trading_ID__c, Resolved_Firm_Trading_IDs__c, Trade_Date__c from Trades__c where Resolved_Firm_Trading_ID__c in :accountIds and Fund_Number__c in (/**'3910', '3911',**/ '3912', '3915') and Dollar_Amount_of_the_transaction__c != null and Number_of_Shares_of_the_transaction__c != null and Trade_Date__c != null and Dollar_Amount_of_the_transaction__c >= 0 and Number_of_Shares_of_the_transaction__c >= 0 FOR UPDATE]){
        for(trades__c trade: tradesList) {
            
            if(date.today().year() == trade.trade_date__c.year()) {
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(ytd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(ytd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(ytd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(ytd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                //system.debug(ytd);
                //system.debug(LoggingLevel.DEBUG, + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                
                //( (date.ValueOf(date.today().month()).divide(3, 0) == date.ValueOf(trade.trade_date__c.month()).divide(3, 0)) )
                if((((date.today().month() - 1) / 3) + 1) == (((trade.Trade_Date__c.month() - 1) / 3) + 1))   {
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(qtd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(qtd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                    accounts.get(trade.Resolved_Firm_Trading_ID__c).put(qtd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(qtd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                    //system.debug(qtd);
                    //system.debug(LoggingLevel.DEBUG, + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                    
                    if(date.today().month()==trade.trade_date__c.month()) {
                        accounts.get(trade.Resolved_Firm_Trading_ID__c).put(mtd.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(mtd.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                        accounts.get(trade.Resolved_Firm_Trading_ID__c).put(mtd.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(mtd.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                        //system.debug(mtd);
                        //system.debug(LoggingLevel.DEBUG, + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
                    }
                }
            } 
            else if(date.today().year()-1==trade.trade_date__c.year()) {
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(py.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(py.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
                accounts.get(trade.Resolved_Firm_Trading_ID__c).put(py.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(py.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
                //system.debug(py);
                //system.debug(LoggingLevel.DEBUG, + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
            }
            accounts.get(trade.Resolved_Firm_Trading_ID__c).put(total.get(trade.fund_number__c)[0], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(total.get(trade.fund_number__c)[0]))+trade.Dollar_Amount_of_The_Transaction__c);
            accounts.get(trade.Resolved_Firm_Trading_ID__c).put(total.get(trade.fund_number__c)[1], ((Decimal)accounts.get(trade.Resolved_Firm_Trading_ID__c).get(total.get(trade.fund_number__c)[1]))+trade.Number_of_Shares_of_the_transaction__c);
            //system.debug(total);
            //system.debug(LoggingLevel.DEBUG, + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
        }
            }
        }
        inprog = true;
        update accounts.values();
        inprog = false;
    }
}
Trigger:
trigger Account_RollupTrades on Account (after update) {
    if(Account_RollupTrades.inprog == false) {
        //set<ID> sID = new set<ID> (trigger.newMap.keySet());
        Account_RollupTrades.execute(trigger.newMap.keySet(), trigger.new);
    }
}



 
Hi,

I'm writing a delete trigger and that is bulkify too. I'm not getting the way to prevent valid data of being delete. like for example if I have 10 record to delete and 2 of them are valid or supposed not to be deleted by anyone. so my use case is those 2 recoreds should will not be deleted . and rest all (8) can be deleted easily.

so if anyone knows about it then please let me know. thanks in advance.

Advaanz Knowledge Systems comes up with data synchronization solutions by developing integration between MySQL and Salesforce and also for data migration using Informatica Cloud
We have successfully completed integration between MySQL and Salesforce CRM for synchronizing the data.

Salient features of this Integration are as follows:
- Through Informatica Cloud we can perform data insertion, updating and deletion.

- Using the CSV files we can do successful data migration.

- It’s not possible to use data loader in professional edition of Salesforce CRM.

- Using Informatica Cloud we can transfer data to Professional edition of Salesforce CRM.

Your search for Data Migration and Integration assistance ends here; please don't hesitate to contact us for assisting on your business needs.

Website - www.advaanz.com.

Email - info@advaanz.com / pradeep.p@advaanz.com

Skype - advaanz / dskvap

Anyone knows what is causing "Login rate exceeded" exception for an (integration) user?
 

Haven't foundnd any reference/answer in "Help" or manual.

 

Can anyone provide me some more information abou this error, because it's really a blocker.

hi friends,

i am using visualforce page and apex class to create standard user and to view user record as well as for edit functionality...

 

i haven't used <apex:detail/> to view record of any particular user...because by using this i am going to standard look and feel...

insted of using detail i have used simple vf  and in that used outputfield to dislay users record

 

here is my code..

 

 

i want to use a command button for reset password ,i haven't written any code in method(reset) of extension ...

how method will be written in extension (say method in extesnion  is reset)

<apex:page standardController="User" tabStyle="MyAdmin__tab" extensions="StaffandUserDetailPageExtension" >  <!--  <apex:detail title="false" relatedList="false"/> -->
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                   
                    <apex:commandButton action="/apex/EditStaffAndUser?id={!id}" value="Edit"/>
                    <apex:commandButton action="/apex/AdminListView?intFocus=5" value="List View"></apex:commandButton>
                <!--    <apex:commandButton action="{!resetpassword}" value="Reset Password"/> -->
                    
                 </apex:pageBlockButtons>
              
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
             
           
                 <apex:outputField value="{!User.User_Types__c}"/> 
                  <apex:pageBlockSectionItem >
                         <apex:outputLabel value="Active"/>
                         <apex:outputfield value="{!User.IsActive}"/>
                  </apex:pageBlockSectionItem> 
                
                  <apex:outputField value="{!User.ProfileId}"/>
                  <apex:outputField value="{!User.FirstName}"/>
                  <apex:outputField value="{!User.Username}"/>
                  <apex:outputField value="{!User.LastName}"/>
                  <apex:outputField value="{!User.Email}"/>
                  <apex:outputField value="{!User.alias}"/>
                  <apex:outputField value="{!User.CommunityNickName}"/>
     
                  
                 
                  </apex:pageBlockSection>
        
            
           
            

          
                    
                    
            <apex:pageBlockSection >

                  
                   
                   <apex:outputField value="{!User.Phone}"/>
                   <apex:outputField value="{!User.Extension}"/>
                   <apex:outputField value="{!User.Fax}"/>
           
                   <apex:outputField value="{!User.Title}"/>
                   <apex:outputField value="{!User.CompanyName}"/>
          
                   <apex:outputField value="{!User.Department}"/>
                   

         
                   
          
                   </apex:pageBlocksection>
              
              
            
      
      
          
            <!-- 
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:outputField value="{!User.EmailEncodingKey}"/>
                   <apex:outputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:outputField value="{!User.LocaleSidKey}"/>
                   <apex:outputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
             --> 
               
        
            
              </apex:pageBlock>
              </apex:form>
   
  
 
 
 


   
</apex:page>

 Thanks in advance

Advaanz Knowledge Systems comes up with data synchronization solutions by developing integration between MySQL and Salesforce and also for data migration using Informatica Cloud
We have successfully completed integration between MySQL and Salesforce CRM for synchronizing the data.

Salient features of this Integration are as follows:
- Through Informatica Cloud we can perform data insertion, updating and deletion.

- Using the CSV files we can do successful data migration.

- It’s not possible to use data loader in professional edition of Salesforce CRM.

- Using Informatica Cloud we can transfer data to Professional edition of Salesforce CRM.

Your search for Data Migration and Integration assistance ends here; please don't hesitate to contact us for assisting on your business needs.

Website - www.advaanz.com.

Email - info@advaanz.com / pradeep.p@advaanz.com

Skype - advaanz / dskvap