• monsterloomis
  • NEWBIE
  • 180 Points
  • Member since 2018

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 31
    Replies
Hi,

I'm currently implementing Shield and due to Birthdate is not supported for encryption I want to move that data into a Custom Field and encrypt that.

I was testing in a developer org but I'm having trouble because this field is used in filters in ListViews using Context Variables (f.e. Date = THIS_MONTH). And when I querry with the Standard Birthdate field I get results, but, if I try with the CustomField I cant get any result.

filter by standard field

filter by custom field

Any idea why this is happening?

Kind Regards




 
Hi Everyone, 

Hope you're doing great. I stuck at some point where I am not aware of how we can write a tests for below piece of code from main class
 
Case obj = new Case();

if(

((obj.field1=='Yes' || obj.field2=='Yes') && checkNull(obj.field3))

||

((obj.field4=='Yes' || obj.field5=='Yes') && checkNull(obj.field6))

)

Note : checkNull() is method in the same class which checks for blank values

I have around 30 such conditions in IF statement and for few of conditions, it is showing that Tests are passed as I checked it in Developer Console

How could we tackle this? 

Thanks for your help in advance
I am having issues with updating task values for a custom field through the Data Loader app. Errors log returns "We can't save this record because the “Task” process failed. Give your Salesforce admin these details." 
I got stuck at one place on one of my requirement on which I am working on.

My use case is as follows:
 
SCENARIO 1: Close Opportunity when Upgrade Order is cancelled 
GIVEN a a person account record in Salesforce AND the has an open upgrade opportunity record in Salesforce AND the opportunity record type equals "Upgrade Opportunity" AND the opportunity stage is not "Closed - Won" WHEN the recipient places an upgrade order AND the status of the upgrade order has been changed to Cancelled THEN the open upgrade opportunity Stage field is set to "Closed - Lost" AND all other related opportunities that also meet this scenario criteria (Upgrade Opportunity, not Closed-Won) are set to "Closed - Lost"
 
CENARIO 2: Close Opportunity when Upgrade Order is shipped (ie Closed in Salesforce)
GIVEN a person account record in Salesforce
    AND thehas an opportunity record in Salesforce 
    AND the opportunity record type equals "Upgrade Opportunity"
    AND the stage of the opportunity record is not Closed-Won
    AND the stage of the opportunity record is not Closed-Lost (unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation)
WHEN the places an upgrade order
    AND the upgrade order has a status of Closed
THEN the open upgrade opportunity Stage field is set to "Closed - Won"
    AND all other related opportunities that also meet this scenario criteria (Upgrade Opportunity, not Closed-Won, not Closed-Lost unless automatically changed to Closed-Lost within 90 days) are set to "Closed - Won"

I have done 1st scenario and works well.For 2nd scenario also I have done almost everything except one scenario where I need to track "the stage of the opportunity record is not Closed-Lost (unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation)

Below is my Apex Class which runs in before update from Apex Trigger:
 
public with sharing class OrderTriggerService extends TriggerService {


public void updateOpportunityStage(){
    Set<Id> setIds = new Set<Id>();
    Map<Id,Order> orderOldMap =(Map<Id,Order>)oldMap;
    Set<Opportunity>  updateOppties=new Set<Opportunity>();

    for (Order childObj : (List<Order>) newList) {

        if(childObj.Account_Record_Type_Name__c == 'INDIA' && childObj.Record_Type_Dev_Name__c == 'Upgrade_Order'){ 
        setIds.add(childObj.AccountId);

        }
    }
    if (setIds.isEmpty()) { return; }

 //Set<Opportunity>  updateOppties=new Set<Opportunity>();
  for(Account acc : [select id,Name
                        (selectId,Name,closedate,amount,StageName
                             from opportunities where 
                            Record_Type_Dev_Name__c='Upgrade_Opportunity') 
                                from Account where id in:setIds]){

                         for(Order orders : (List<Order>) newList){            
                                for(Opportunity opps : acc.opportunities){

                                    if(opps.StageName<>'Closed Won' && orders.Status!=orderOldMap.get(orders.Id).Status && orders.Status=='Cancelled'){
                                             opps.StageName='Closed Lost'; 


                                    }

                            else if((opps.StageName<>'Closed Won'||opps.StageName<>'Closed Lost')&& orders.Status!=orderOldMap.get(orders.Id).Status && orders.Status=='Closed'){         
                                        opps.StageName='Closed Won';

                             }

                            updateOppties.add(opps);
                         }
                         }
                     }

                    List<Opportunity> updateopps=new List<Opportunity(updateOppties);
                    update updateopps;

}
  }
I am not able to find a way to track opp.stagename<>'Closed Lost'(unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation) in my class.
Kindly help.

Any help will be greatly appreciated.

Many thanks in advance
 
How can I find Salesforce's every relationship?

I want create Master-Detail Field or LookUp Relationship Field by "Salesforce Metadata Api"
Problem occurred here!

When Child Relationship Name duplicated, that make error.
So.....First, I find every RelationShip by Salesforce Query and,
I want Find overlapping Child Relationship Name..

How can I do it?
All visualforce pages on sandbox cannot make use of attribute lightningStylesheets="true". 
The message "failed to load" can be seen in browser debugger, the page displayed but without any styles (classic or lightning).

Any advice, thank you very much in advance.
 
Hello, 

I am looking to populate the address fields by using the longitude and latitude coordinates. 

I can look this information up with Google Maps API but I don't know how to get this information into my Salesforce fields, 
Here is an example of google link https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&key=AIzaSyB9SidQvZbhRlDax3Vvg8ak0hE0nxk7seo

Can anyone assist?

Thanks
-Heather
I have Created a List View button on OrderLineItem__c object and added it in related list of its parent Order__c, when i click on that button i am below error.
A problem with the Onclick Javascript for this button or link was encountered:

Unexpected Identifier
Code Is:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 

var IdsToClone = {!GetRecordIDs($ObjectType.Order_Line_Item__c)}; 
var url; 
if(IdsToClone.length == 0){ 
alert("You must choose at least one record to clone"); 

else if(IdsToClone.length > 1) { 
alert("You can't clone more than one record"); 

else{ 
url = "/apex/OrderLineItemsManagement?id="IdToClone; 

if (sforce.console.isInConsole()) { 
srcUp(url); 
} else { 
window.open(url,'_blank'); 
}
Hi,

I'm currently implementing Shield and due to Birthdate is not supported for encryption I want to move that data into a Custom Field and encrypt that.

I was testing in a developer org but I'm having trouble because this field is used in filters in ListViews using Context Variables (f.e. Date = THIS_MONTH). And when I querry with the Standard Birthdate field I get results, but, if I try with the CustomField I cant get any result.

filter by standard field

filter by custom field

Any idea why this is happening?

Kind Regards




 
Hi Everyone, 

Hope you're doing great. I stuck at some point where I am not aware of how we can write a tests for below piece of code from main class
 
Case obj = new Case();

if(

((obj.field1=='Yes' || obj.field2=='Yes') && checkNull(obj.field3))

||

((obj.field4=='Yes' || obj.field5=='Yes') && checkNull(obj.field6))

)

Note : checkNull() is method in the same class which checks for blank values

I have around 30 such conditions in IF statement and for few of conditions, it is showing that Tests are passed as I checked it in Developer Console

How could we tackle this? 

Thanks for your help in advance
I got stuck at one place on one of my requirement on which I am working on.

My use case is as follows:
 
SCENARIO 1: Close Opportunity when Upgrade Order is cancelled 
GIVEN a a person account record in Salesforce AND the has an open upgrade opportunity record in Salesforce AND the opportunity record type equals "Upgrade Opportunity" AND the opportunity stage is not "Closed - Won" WHEN  places an upgrade order AND the status of the upgrade order has been changed to Cancelled THEN the open upgrade opportunity Stage field is set to "Closed - Lost" AND all other related opportunities that also meet this scenario criteria (Upgrade Opportunity, not Closed-Won) are set to "Closed - Lost"

I have done the scenario and code is also getting saved but getting System.NullPointerException:Attempt to de-reference a null Object when try to change the status of an upgrade order from a value say"Order-Placed" to "Cancelled"

Below is my Apex Class which runs in before update from Apex Trigger:
 
public with sharing class OrderTriggerService extends TriggerService {
public void updateOpportunityStage(){
        Set<Id> setIds = new Set<Id>();
        Map<Id,Order> orderOldMap =(Map<Id,Order>)oldMap;
        Map<Id,Order> orderNewMap=(Map<Id,Order>)newMap;
        Set<Opportunity>  updateOppties=new Set<Opportunity>();
        DateTime statusChange= System.now()-90;
        
        for (Order childObj : (List<Order>) newList) {
            if(childObj.Account_Record_Type_Name__c == 'Recipient' && childObj.Record_Type_Dev_Name__c == 'Upgrade_Order'){ 
            setIds.add(childObj.AccountId);
               
            }
        }
        if (setIds.isEmpty()) { return; }
        
        Map<ID, Account> parentAccts = new Map<Id, Account>(
                                          [select id, Upgrade_Order_Booked_Date__c, Upgrade_Order_Status__c, Order_Cancellation_Reason__c,Upgrade_Order_Number__c,Order_Cancellation_Date__c,
                                          (select id, Name, Booked_Date__c, Status ,Order_Cancellation_Reason__c,Oracle_Order_Number__c,Order_Cancellation_Date__c
                                            from Orders ) 
                                           from Account where id in :setIds]);
        System.debug('updateOrderUpgrade parentAccts: ' + parentAccts);
        
        Map<Account, Order> accountToLatestOrder = new Map<Account, Order>();
        for (Account acc : parentAccts.values()) {
            if (acc.orders.isEmpty() == false) {
                accountToLatestOrder.put(acc, acc.orders[0]);
            }
        }
         
    
      for(Account acc : [select id, Upgrade_Order_Booked_Date__c, Upgrade_Order_Status__c, Order_Cancellation_Reason__c,Upgrade_Order_Number__c,Order_Cancellation_Date__c,
                         			(select Id,Name,closedate,amount,StageName,Oracle_Order_Number__c,Status_Last_Changed_On__c
                                     from opportunities where Record_Type_Dev_Name__c='Upgrade_Opportunity') 
                         			from Account where id in : setIds]){
                             
                             for(Order orders : accountToLatestOrder.values()){            
                             		for(Opportunity opps : acc.opportunities){
                                 
                                 		if(opps.StageName<>'Upgrade-Closed Won' && orders.Status!=orderOldMap.get(orders.Id).Status && orders.Status=='Cancelled'){
                                 		
                                                 opps.StageName='Upgrade - Closed Lost'; 
                                                 
                                                 
                                 		}
                               
                            	
                                 System.debug('updateOpportunityStage Opportunity: ' + opps);  
                    			updateOppties.add(opps);
                             }
                             }
                         }
        
         				List<Opportunity> updateopps=new List<Opportunity>(updateOppties);
        				update updateopps;
        			}
}

Also,attached is the screenshots

Errors snapshot taken from UI

Kindly help me.

Any help will be greatly appreciated.

Many thanks​

I am new with triggers and I am trying to achieve the following. Every time a BundlePrice field is inserted or updated it should automatically update the standard price with that info according the exchange rate.
This is the trigger that I made.

 

trigger UpdateStandardPrices on Product2 (after insert, after update) {

//Update the Standard price in all currencies from the Cost price on the Product. Cost Price is always in SEK
//Create a PriceBookEntry if it's a new Product

System.Debug('USP TRIGGER');

//This trigger will cause recursion if it's not stopped. 
//The TriggerMonitor class is static, and remains for the lifetime of the insert/update
//This prevents recursion.
//string TriggerName = 'UpdateStandardPrices';
if (TriggerMonitor.runOnce())
{       
    //TriggerMonitor.ExecutedTriggers.add(TriggerName);


    // GET ALL DATA //
    Id PriceBookId = [SELECT Id From Pricebook2 WHERE IsStandard=TRUE].Id;                                                          //Get the ID of the Standard Price Book
    list<CurrencyType> ActiveCurrencies = [SELECT ISOCode, ConversionRate FROM CurrencyType WHERE IsActive=TRUE];                   //Get a list of all active currencies
    list<Product2> Products = new List<Product2>([SELECT Id, Bundle_Price__c, CurrencyIsoCode FROM Product2 WHERE Id in :Trigger.new]);  //Get a list of all new entries
    list<PricebookEntry> resultList = new list<PricebookEntry>();                                                                   //List to populate and update

    for( Product2 product : Products)
    {

        list<PricebookEntry> loopList = new list<PricebookEntry>([Select Id, CurrencyISOCode FROM PricebookEntry WHERE PricebookEntry.Product2Id =: product.Id]); //Get a list of all entries in the Standard Price Book for the product id

        for(CurrencyType c : ActiveCurrencies)
        {

            integer currencyExists = 0;                 //Reset the currency exists flag
            PricebookEntry price = new PricebookEntry();

            for(PricebookEntry l : loopList)        
            {                                           //Is there already an entry in the currency
                if(l.CurrencyIsoCode == c.IsoCode)
                    currencyExists = 1;
            }


            if(currencyExists == 0)
            {                                           //Does not exist in this currency: Insert new StandardPrice

                price.UnitPrice = product.Bundle_Price__c * c.ConversionRate; 
                price.Product2Id = product.Id;
                price.CurrencyISOCode = c.IsoCode;
                price.Pricebook2Id = PriceBookId;
                price.IsActive = TRUE;
                insert price;
            }
            else
            {                                           //Exist in this currency: Update with new StandardPrice
                for(PricebookEntry l : loopList)        
                {                                       //Loop through to find the unique Id for the PricebookEntry

                    if(l.CurrencyIsoCode == c.IsoCode)
                        price.Id = l.Id;
                }

                price.UnitPrice = product.Bundle_Price__c* c.ConversionRate;
                price.IsActive = TRUE;
                resultList.add(price);
            }
        }

    }
    update resultList;
}


What the trigger does is checks currencies check rate and add them to the standard price. But when i test it, it change the price to all currencies the same and ignores the rate. I need to edit the product so the rates will get changed. What I am doing wrong?
Additionally how can I update the trigger to check the PricebookId(sweden) that I have and add the corresponding Standardprice(SEK) to the Swedish price-book.
Any help to reach this mission will be highly appreciated.

 

Thanks, Darko

I got stuck at one place on one of my requirement on which I am working on.

My use case is as follows:
 
SCENARIO 1: Close Opportunity when Upgrade Order is cancelled 
GIVEN a a person account record in Salesforce AND the has an open upgrade opportunity record in Salesforce AND the opportunity record type equals "Upgrade Opportunity" AND the opportunity stage is not "Closed - Won" WHEN the recipient places an upgrade order AND the status of the upgrade order has been changed to Cancelled THEN the open upgrade opportunity Stage field is set to "Closed - Lost" AND all other related opportunities that also meet this scenario criteria (Upgrade Opportunity, not Closed-Won) are set to "Closed - Lost"
 
CENARIO 2: Close Opportunity when Upgrade Order is shipped (ie Closed in Salesforce)
GIVEN a person account record in Salesforce
    AND thehas an opportunity record in Salesforce 
    AND the opportunity record type equals "Upgrade Opportunity"
    AND the stage of the opportunity record is not Closed-Won
    AND the stage of the opportunity record is not Closed-Lost (unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation)
WHEN the places an upgrade order
    AND the upgrade order has a status of Closed
THEN the open upgrade opportunity Stage field is set to "Closed - Won"
    AND all other related opportunities that also meet this scenario criteria (Upgrade Opportunity, not Closed-Won, not Closed-Lost unless automatically changed to Closed-Lost within 90 days) are set to "Closed - Won"

I have done 1st scenario and works well.For 2nd scenario also I have done almost everything except one scenario where I need to track "the stage of the opportunity record is not Closed-Lost (unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation)

Below is my Apex Class which runs in before update from Apex Trigger:
 
public with sharing class OrderTriggerService extends TriggerService {


public void updateOpportunityStage(){
    Set<Id> setIds = new Set<Id>();
    Map<Id,Order> orderOldMap =(Map<Id,Order>)oldMap;
    Set<Opportunity>  updateOppties=new Set<Opportunity>();

    for (Order childObj : (List<Order>) newList) {

        if(childObj.Account_Record_Type_Name__c == 'INDIA' && childObj.Record_Type_Dev_Name__c == 'Upgrade_Order'){ 
        setIds.add(childObj.AccountId);

        }
    }
    if (setIds.isEmpty()) { return; }

 //Set<Opportunity>  updateOppties=new Set<Opportunity>();
  for(Account acc : [select id,Name
                        (selectId,Name,closedate,amount,StageName
                             from opportunities where 
                            Record_Type_Dev_Name__c='Upgrade_Opportunity') 
                                from Account where id in:setIds]){

                         for(Order orders : (List<Order>) newList){            
                                for(Opportunity opps : acc.opportunities){

                                    if(opps.StageName<>'Closed Won' && orders.Status!=orderOldMap.get(orders.Id).Status && orders.Status=='Cancelled'){
                                             opps.StageName='Closed Lost'; 


                                    }

                            else if((opps.StageName<>'Closed Won'||opps.StageName<>'Closed Lost')&& orders.Status!=orderOldMap.get(orders.Id).Status && orders.Status=='Closed'){         
                                        opps.StageName='Closed Won';

                             }

                            updateOppties.add(opps);
                         }
                         }
                     }

                    List<Opportunity> updateopps=new List<Opportunity(updateOppties);
                    update updateopps;

}
  }
I am not able to find a way to track opp.stagename<>'Closed Lost'(unless the stage was automatically set to Closed-Lost within the past 90 days due to an order cancellation) in my class.
Kindly help.

Any help will be greatly appreciated.

Many thanks in advance