• Andray Gaust
  • NEWBIE
  • -6 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
Friends, who loves to play games at their leisure? I've only recently started to get involved in this. I found a cool casino site https://betsofa.life Where there are new and interesting slot machines. Who loves excitement and wants to try their luck, then I advise you to look at this site.

All, 

So i created two custom objects let's say fruits (Grapes, Bananas, Mangoes and Apples). What i want to do is if i select an option "Apple".. it should show another field(Type of fruit: ") that should let me select ("Green Apple, "Red Apple"). How can i do this?

I wrote a trigger that fires when a new Rental (custom object) is created. What the trigger should do is query the AccountID associated with the rental, then find the Contacts associated with that accountID and associate them directly with the rental. It works in the sandbox just fine, and I was able to get it to production where it also works fine. However the code coverage is at 54% and i have no idea why.It brought my overall code coverage down to 76% and I am having a world of trouble updating this trigger to include some new code because of these coverage issues.

Also I see lots of color coding and such from different posts. what are you guys using to write your code? I am very new to this. Thank you in advance for your help.

Below is the Trigger, followed by the Test Class

TRIGGER START

//Creates the trigger AssingPrimaryBrideGroom1, whenever a new Rental record is created. the job is defined to run BEFORE the record is saved/updated
trigger AssignPrimaryContactTest on Rental__c (before insert, before update)
{
    
// Step 1: Creates a blank set to contain the AccountID supplied in a new Rental (set is named AccountIDSet on this line)
Set<String> AccountIDSet = new Set<String>();
//for each new Rental created....  
//Creates variable newRental for any new Rental(s) created
  for (Rental__c newRental : Trigger.new)
  {
    ////if the Account_Rental_c (AccountID) field is notblank
    if (newRental.Account_Rental__c != null)
    {
    //add the AccountID from the new rental to the AccountIDSet created earlier
      AccountIDSet.add(newRental.Account_Rental__c);    
    }
    
    
  }
 
  // Step 2: Query for all the contacts in Step 1
  //create a list of ALL contacts in salesforce where the position is Primary, and select only the properties needed
  List<Contact> primaryContacts = [SELECT Id, AccountId, Position__c FROM Contact WHERE AccountId IN :AccountIDSet AND Position__c = 'Primary'];
  //create a list of ALL contacts in salesforce where the Booking position is Bride, and select only the properties needed
  List<Contact> brideContacts = [SELECT Id, AccountId, Position__c, Booking_Position__c FROM Contact WHERE AccountId IN :AccountIDSet AND Booking_Position__c = 'Bride'];
  //create a list of ALL contacts in salesforce where the position is Groom, and select only the properties needed
  List<Contact> groomContacts = [SELECT Id, AccountId, Position__c, Booking_Position__c FROM Contact WHERE AccountId IN :AccountIDSet AND Booking_Position__c = 'Groom'];
 
 
    // Step 3: Make a Map that lets you search for Contacts by AccountID
  Map<String, Contact> AccountToContactMap = new Map<String, Contact>();
  //foreach Contact in the primaryContacts variable (from step 2)
  for (Contact vCnt : primaryContacts)
  {
    //put the Contact's AccountID, and the users other fields into the empty map
    AccountToContactMap.put(vCnt.AccountID, vCnt);
  }
 
      // Step 3a: Make a Map that lets you search for Contacts by AccountID
  Map<String, Contact> AccountToBrideMap = new Map<String, Contact>();
  //foreach Contact in the brideContacts variable (from step 2)
  for (Contact vBride : brideContacts)
  {
    //put the Contact's AccountID, and the users other fields into the empty map
    AccountToBrideMap.put(vBride.AccountID, vBride);
  }
 
      // Step 3b: Make a Map that lets you search for Contacts by AccountID
  Map<String, Contact> AccountToGroomMap = new Map<String, Contact>();
  //foreach Contact in the groomContacts variable (from step 2)
  for (Contact vGroom : groomContacts)
  {
    //put the Contact's AccountID, and the users other fields into the empty map
    AccountToGroomMap.put(vGroom.AccountID, vGroom);
  }
 
   // Step 4: Get the matching Contact in the Map by AccountID!
  //for each new case created
  for (Rental__c newRental : Trigger.new)
  {
    if (newRental.Rental_Event_Type__c == 'Wedding/ Reception')
    {   
        if (newRental.Account_Rental__c != null)
        {
            //reference the map, retrieving the AccountID matching what was supplied in the rental record
          Contact aContact = AccountToContactMap.get(newRental.Account_Rental__c);
          if (aContact != null)
          {
            // the new case Primary_Rental_Contact__c will  be set to the ID retrieved from the map
            newRental.Primary_Rental_Contact__c = aContact.Id;
          }
          
          Contact bContact = AccountToBrideMap.get(newRental.Account_Rental__c);
          if (bContact != null)
          {
            // the new case Primary_Rental_Contact__c will  be set to the ID retrieved from the map
            newRental.Bride__c = bContact.Id;
          }
          
          Contact gContact = AccountToGroomMap.get(newRental.Account_Rental__c);
          if (gContact != null)
          {
            // the new case Primary_Rental_Contact__c will  be set to the ID retrieved from the map
            newRental.Groom__c = gContact.Id;
          }
        }
        

    }
    else
    {
        //if the new rentals AccountID is not null
        if (newRental.Account_Rental__c != null)
        {
          //reference the map, retrieving the AccountID matching what was supplied in the rental record
          Contact aContact = AccountToContactMap.get(newRental.Account_Rental__c);
          if (aContact != null)
          {
            // the new case Primary_Rental_Contact__c will  be set to the ID retrieved from the map
            newRental.Primary_Rental_Contact__c = aContact.Id;
          }
        }       
    
    }
  }
 
 }

TRIGGER END

CLASS START


@isTest
public class TestAssignPrimaryProd1 {
    static testMethod void insertNewRental() {
       
       Rental__C rentalToCreate = new Rental__C();
       
       // Do you recognize these fields?
       rentalToCreate.RecordTypeID  = '0126A000000Do2IQAS';
       rentalToCreate.Account_Rental__c = '0016A000009A6pUQAS';
       rentalToCreate.Rental_Date__c  = date.newInstance(2014, 9, 15);
       rentalToCreate.Name  = 'new';
       rentalToCreate.Rental_Event_Type__c  = 'Private_Event';

       
       insert rentalToCreate;
    }
}


CLASS END
I have created the following cutomer health formula field that works perfectly.

IF( ISPICKVAL( Successful_Health_Check__c ,"No" ) ,0,10 )+
IF( ISPICKVAL( Usage_at_Expected_level__c ,"No" ) ,0,25 ) + 
IF( ISPICKVAL( All_Licenses_Paid_For__c  ,"No" ) ,0,10 ) + 
IF( ISPICKVAL( NPS_Greater_Than_6__c ,"No" ) ,0,20 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"3 Months" ) ,0,0 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"6 Months" ) ,0,10 ) + 
IF( ISPICKVAL( Last_In_Person_Meeting_Time_Frame__c ,"12 Months" ) ,0,30 ) + 
IF( ISPICKVAL( Change_in_Management__c ,"Yes" ) ,0,5 ) +
IF( ISPICKVAL( Overdue_30_Days__c ,"Yes" ) ,0,20 ) +
IF( ISPICKVAL( Overdue_60_Days__c  ,"Yes" ) ,0,35 ) +
IF( ISPICKVAL( Level_2_Support_Tickets__c  ,"Yes" ) ,0,55 ) +
IF( ISPICKVAL( Identified_Red_Flag_Issue__c  ,"Yes" ) ,0,55 )

We are categorizing customers into 3 categories based on the score that is calcuated from this formula.

Green = 0 - 30 
Yellow = 31 - 51 
Red 51- 9999

I would like to create a formula field that indicates their status and gives a visual indicator.  I have the following formula in an opporuntiy field that works well in categorizing Opps by Stage.

IMAGE(
CASE(StageName , 
"Negotiating Price & Implementation", "/img/samples/light_green.gif",
"Qualifying", "/img/samples/light_yellow.gif",
"Closed Lost", "/img/samples/light_red.gif",
"/s.gif"),
"status color")

I am having a tough time modifying that formula to show Red, Yellow or Green based on the following scoring tiers:

Green = 0 - 30 
Yellow = 31 - 51 
Red 51- 9999

Any ideas would be most appreciated
Dear Team,
 
I want to know count the number of public group(s)(starts with P) an account is shared with. Can anyone please help us to creating a new trigger.
 
Let ‘say: In one account we have number of public group’s start with P. So we want to count the public groups which are start with P. The count will be populate field called as "PublicGroup_Count__c"
Thanks
 
Hi all,

I'm a bit new to this so I apologize if this is not even possible.

I created a Button on a custom Object I have with the intention of having a checkbox on the related Opportunity updated when the button is clicked. This is what I have:

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

// identify the record

var o = new sforce.SObject("Opportunity");

o.id = "{!Medical_Consult__c.Patient__c}"; // Medical_Consult__c is my custom Object name Patient__c is the Opportunity lookup

// make the field change

o.Consult_Document_Fully_Completed__c = true; //This is the field on the Opportunity

// save the change

sforce.connection.update([o]);

//refresh the page

window.location.reload();

I'm not getting any errors when I click this button but the field is not updated on the Opportunity.

Any help would be greatly appreciated.
Hi,

I can't pass the challenge (https://developer.salesforce.com/trailhead/force_com_dev_intermediate/lex_dev_lc_basics/lex_dev_lc_basics_events). This is the error when check challenge:

Challenge Not yet complete... here's what's wrong: 
The campingList JavaScript controller isn't adding the new record to the 'items' value provider.


I tryed in the browser add new Camping Items and it's working correctly. The item is added to database and the list is updated.

This is my code:

campingList Component
<aura:component controller="CampingListController">
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
    
    <div class="slds-page-header" role="banner">

      <div class="slds-grid">

        <div class="slds-col">

          <p class="slds-text-heading--label">Camping Items</p>

          <h1 class="slds-text-heading--medium">My Camping Items</h1>

        </div>

      </div>

    </div>

      
  <div aria-labelledby="newitemform">

      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <c:campingListForm />
    
      </fieldset>

	</div>
    
    
     <aura:attribute name="items" type="Camping_Item__c[]"/>

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping List Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="campItem">
                    <c:campingListItem item="{!campItem}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

campingList Controller.js
({
    
    doInit: function(component, event, helper) {
    
        var action = component.get("c.getItems");
    
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
    
        $A.enqueueAction(action);
    },    
    
    handleAddItem: function(component, event, helper) {
        var item = event.getParam("item");
                
        var action = component.get("c.saveItem");
        action.setParams({
            "item": item
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {        
                var theItems = component.get("v.items");
                theItems.push(item);
                component.set("v.items",theItems);
            }
        });
        $A.enqueueAction(action);
    }
    
})

CampingListController
public with sharing class CampingListController {

    @AuraEnabled 
    public static List<Camping_Item__c> getItems() {
        return [SELECT Id, Name, Price__c, Quantity__c, Packed__c FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        upsert item;
        return item;
    }
}

CampingListForm Component
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': '0',
                    'Quantity__c': '0' }"/>
	<aura:registerEvent name="addItem" type="c:addItemEvent"/>
    
  <div aria-labelledby="newitemform">
      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <legend id="newitemform" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add Camping Item
        </legend>
    
        <form class="slds-form--stacked">
    
          <div class="slds-form-element slds-is-required">
              <div class="slds-form-element__control">
                  <ui:inputText aura:id="name" label="Camping Item Name"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Name}"
                      required="true"/>
              </div>
         </div>
            
          <div class="slds-form-element">
              <ui:inputCheckbox aura:id="packed" label="Packed?"
                  class="slds-checkbox"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Packed__c}"/>
          </div>
            
        <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputCurrency aura:id="price" label="Price"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Price__c}" />
    
              </div>
          </div>
    
         <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputNumber aura:id="quantity" label="Quantity"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Quantity__c}"/>
    
              </div>
          </div>
    
          <div class="slds-form-element">
              <ui:button label="Create Camping Item"
                  class="slds-button slds-button--brand"
                  press="{!c.clickCreateCampingItem}"/>
          </div>
    
        </form>
    
      </fieldset>
</div>

</aura:component>

CampingListForm Controller.js
({    
    
    clickCreateCampingItem : function(component, event, helper) {
        
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("name");
        var expname = nameField.get("v.value");
        if ($A.util.isEmpty(expname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }

        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price) || isNaN(price) || (price <= 0.0)){
            validCamping = false;
            priceField.set("v.errors", [{message:"Camping Item price can't be blank."}]);
        }
        else {
            priceField.set("v.errors", null);
        }
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity) || isNaN(quantity) || (quantity <= 0)){
            validCamping = false;
            quantityField.set("v.errors", [{message:"Camping Item quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        if(validCamping){
            
            helper.createItem(component);
            
        }
        
    },
})

CampingListForm Helper.js
({
    
     createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
        addEvent.fire();
        component.set("v.newItem",
                     { 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': 0,
                    'Quantity__c': 0});
    }
})

Could anyone help me?

Thanks,
Regards.
Hello all,

Thanks for looking at my question. I am new to SF and am trying to get certified in ADM 201 and DEV 401.

This question goes out to all certified developers and admins with the above completed, recently would be great.

Was looking at the following link:
http://forcecertified.com/2009/08/14/recorded-sessions-of-dev-401-dev-501-salesforce-training-available-online-for-free/
and am very disapponted. Questions seem to be so specific that nothing my trainer taught me applies.

Want to know the following:
1. Is that exam realistic?
2. What is the best guide to study for the exam ... any suggestion/s are appreciated.
3. Length of time I can expect it will take to complete the same.

I looked at the questions posted previously by other users. Most of links in those replies are not active any more.
Thus I am choosing to post this again.

Thanks for your help,
Murali.
Hello developer heroes!

I'm working through the Apex modules on Trailhead and can't seem to get past this one: https://developer.salesforce.com/en/trailhead/force_com_programmatic_beginner/apex_triggers/apex_triggers_bulk.

Hopefully this doesn't read like a 'please complete the course for me' kinda post, but I have written a trigger that I believe meets the criteria but it isn't passing the check, so I wanted to seek the guidance of the experts.

The challenge is to do this:

Create an Apex trigger for Opportunity that adds a task to any opportunity set to 'Closed Won'.

To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.The Apex trigger must be called 'ClosedOpportunityTrigger'

- With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
- To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
- This challenge specifically tests 200 records in one operation.


And here is the trigger I have come up with, which compiles OK and stands up to a manual (though admittedly unbulkified) test:
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for (Opportunity opp : [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Closed Won' AND Id IN :Trigger.new]){
                    
            taskList.add(new Task(Subject = 'Follow Up Test Task',
                                  WhatId = opp.Id));
       
    }

    if(taskList.size()>0){
        
        insert taskList;
        
    }
    
}
I have tried replacing the SOQL with a straightforward 'for (Opportunity opp : Trigger.new)' and having the taskList.add inside an IF that checks for Closed Won - no luck. I also thought about checking to see if the stage was being changed to Closed Won, rather than the trigger firing on every edit, but I don't think this is what the module is asking for.

Where do you think I'm going wrong?

Huge thanks in advance!
Hey Everyone,

Recently a new error has come up when one of my batch classes runs causing trades from the day before not to post. This code has worked fine since implemented over 6 months ago. I've never dealt with a Heap Size error before so I'm not sure how to fix it. From what I've researched it involves having to many objects, but the code seems pretty efficient. Unless it's the test class, I don't know where the problem would be. Please take a look and let me know if you can help!

Error:
Trades_CascadeAccounts: System.LimitException: Apex heap size too large: 6220442
Trades_CascadeAccounts: System.LimitException: Apex heap size too large: 6220442
Trades_CascadeAccounts: System.LimitException: Apex heap size too large: 6220442
Trades_CascadeAccounts: System.LimitException: Apex heap size too large: 6220442
Trades_CascadeAccounts: System.LimitException: Apex heap size too large: 6220442

Apex 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()
                   )
                            );
            }
           
        // Roll up the trades based on the Resolved Firm Trading ID field
        Trades__c[] tradesList = [
            select Dollar_Amount_of_the_transaction__c, Fund_Number__c, Number_of_Shares_of_the_transaction__c,
                Resolved_to_Rep_Trading_ID__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')       // NIOR I; NS Income; NS HI; NS Income II
               and Dollar_Amount_of_the_transaction__c != null      // prevents null pointers below
               and Number_of_Shares_of_the_transaction__c != null   // prevents null pointers below
               and Trade_Date__c != null                            // prevents null pointers below
               // Negative values are ignored for roll-up purposes
               and Dollar_Amount_of_the_transaction__c >= 0
               and Number_of_Shares_of_the_transaction__c >= 0
        ];
           
            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 }
                };

            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);

                    if( (Decimal.ValueOf(date.today().month()).divide(3, 0) == Decimal.ValueOf(trade.trade_date__c.month()).divide(3, 0)) )   {
                        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);

                        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);
                        }
                    }
                } 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);
                }
                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);
            }
        }
     inprog = true;
     update accounts.values();
     inprog = false;
    }
}


Apex 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(sID, trigger.new);
    }
}

Hi,

 

I do have a doubt regarding Salesforce.com.

 

Can we develope Games in the Salesforce.com platform?

  • August 07, 2013
  • Like
  • 0



I have a requirement where user can be allowed to fill its Wedding Anniversary Date in 2 formats :-

- MM/DD/YYYY
- MM/DD

I know with standard Date field this is not possible, so I may need to use text field type.

However, I am struggling to write Validation Rule for the same. This is my Val Rule in construction :-

(NOT(ISNUMBER(RIGHT(Wedding_Anniversary__c, 2)) && ISNUMBER(LEFT(Wedding_Anniversary__c, 2)) && VALUE(LEFT(Wedding_Anniversary__c, 2) ) <= 12 && VALUE(RIGHT(Wedding_Anniversary__c, 2)) <= 31 && VALUE(LEFT(Wedding_Anniversary__c, 2) ) <> 0 && VALUE(RIGHT(Wedding_Anniversary__c, 2)) <> 0 && CONTAINS(MID( Wedding_Anniversary__c, 1, 5),'/'))) && 
NOT (ISBLANK (Wedding_Anniversary__c))

Can anyone please assist me?


Thanks,

Vimal

Hi all,

 

I have a custom object (Contract_Line__c) that has a Master-Detail field (back to Contract). I'm making some changes to my code and no longer want that relationship there - in fact, I want a lookup relationship in its place.

 

I have it working in the sandbox - I was able to change my code (and unit tests that use that field), then remove the master-detail field from my custom object.

 

However - I am not able to deploy the solution because the unit tests no longer populate the Contract__c field which is a master-detail field and therefore mandatory.

I also cannot delete the field in production because 27 apex classes reference it.

I can't change the apex classes because I am unable to deploy the classes (see above).

 

I'm out of options - all I want to do is delete one field from a custom object!!!

 

Please help - I'm tearing my hair out!

 

Andy

 

 

Hi,

Am unable to refresh any of the resources in the IDE from the server.

When am trying to refresh a page from the web, getting an Exception saying:

 

 

Unable to refresh resource 'MileaeExension.cls':
com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Unable to refresh resource 'MileaeExension.cls':


com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Please assist to rectify the issue. 

 

Thanks in advance,

VNath