• JJames
  • NEWBIE
  • 110 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 50
    Questions
  • 33
    Replies
I have a challenge in a current design that the client requires datasheets for each product that is added to the quote to be saved as a pdf on that quote in the notes and attachments. I use a future callout when the item is saved that downloads the datasheet from a URL and this works fine under normal quote creation.
The issue I have is when a quote is cloned, the future callout is called in a batch method which is not allowed by salesforce. I receive this error when I copy:
10:26:54:808 FATAL_ERROR System.AsyncException: Future method cannot be called from a future or batch method: class.savePdfFromBlob(String, Id, String)
I know there is queueable methods but I am not sure how to call upon this with the data i need to download the appropriate datasheets. In the example salesforce gives:
public class AsyncExecutionExample implements Queueable { public void execute(QueueableContext context) { Account a = new Account(Name='Acme',Phone='(415) 555-1212'); insert a;
} }
Is there a way to pass information to this queueable context call? I would need to pass the list of datasheets that need to be downloaded.
Or is there another way around this to download all of the datasheets on the quote copy?
  • January 28, 2018
  • Like
  • 0
I am trying to change the email from a schedulable class for old users to purge their info from the system, a requirement of the client's to not show old employees information.  I know you can manually change the email and click the checkbox saying: "Generate new password and notify user immediately" but if i change it through apex it doesn't change.  Is there a way to enable that checkbox when updating a users info from apex? or a way that I can change the old user's email address without email confirmation or manual steps??
Thanks,
  • December 22, 2017
  • Like
  • 0
I am implementing a request to throw an error message to the user instead of going to the edit page if the object is in a certain status. My plan was to create a visualforce page and display the error if the object meets the criteria for the error message, and route to the edit page if not.

Is it possible to do this without the VF page, directly through the onclick javascript for the button click? How might I implement that? 

I just want to replace the standard edit button with a custom that would throw the error before the user gets to the edit page, instead of it throwing an error upon saving the modified data.
  • December 04, 2017
  • Like
  • 0
Hi,

I am looking for a solution where I need to provide a notification to the user when a certain action takes place on a managed package apex page. I don't have access to the page itself as it is protected, but I need to create a notification to tell the user if a certain action took place.
The managed package allows apex code on the action but it returns a Map<string,string> with the page reference so I don't really have access to creating the page reference either, unless it is defined in the URL, because I can only pass the url not an object.

Is there a best practice or any solution that you can think of to generate a message to the user through the apex class? I can't use the error message because i still need the action to process, and when I addError it doesn't process the action.

Any help is much appreciated.
Thanks.
I have a custom approval process that goes through 5 teirs of approvals, based on the discount of the quote and the level of the person.  The problem is, when the first approver tries to approve the record, i get the following error:

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger ApprovalProcessHandler caused an unexpected exception, contact your administrator: ApprovalProcessHandler: execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []: Trigger.ApprovalProcessHandler: line 83, column 1". 

line 83 is just : 
Approval.ProcessResult result = Approval.process(req);

and req is defined as: 
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                        req.setComments('Submitted for approval. Please approve.');
                        req.setObjectId(tQuote.id);                        
                        req.setNextApproverIds(new Id[] {tUser.id});

This doesn't make sense to me because the last approval process in the list has an entry criteria of "TRUE" which means every single approval process should his this step.  Also, when I give the approver modify all access to the record that is being approved, it works fine.  I don't want to give them modify all to the record though.  What is going on here? I didn't think a user had to have privelages to submit a record for approval? (i've tried with locked and unlocked records, problem exists in both) 
I am setting up an approval process and want to allow the user to select which user will be assigned as the approver for the process. The OOB functionality allows the user to select another user, but I only want the user to be able to select from a specified list of users.

I know that there is a queue functionality but that is not the solution I am seeking, as I only want a single user to be the approver.
Does anyone have any insight on how I would accomplish this? Thanks!
I am having an issue in my org surrounding attachments and SSO login.  I have a custom link that is used to redirect the users when logging in through SSO.  When an attachment is added to an object, it saves the attachment to a location using the default url, and when a user clicks this they are directed to the login page instead of it redirecting to the sso unique url.  Is there a way to solve this issue?
It worked in the sandboxes, but the sandboxes didn't use a custom url like prod environment does.  I believe it is the difference in URLs that is causing the issue.
Any help is appreciated.
Thanks.
Hi,

I have a sandbox and a prod environment that I am generating a PDF proposal from.  I am using the exact same code for each but for some reason the sandbox is generating the correct (8.5inx11in) and the prod envinroment is generating a longer length. This is causing problems because we add a flyer at the end from an image and it fits in the normal sized paper but the longer one makes it look bad.

Aside from needing a solution to make the prod version match the sandbox version and size, I would like to understand what could be causing this to happen.  Any idea what's going on here?

Thanks!
  • April 17, 2017
  • Like
  • 0
I have a custom object in which I have selected 20 fields to track. When changing these fields, it doesn't seem to add anything to the related list on the object page.
Any idea what would cause these not to show up or are there any type of additional configuration that needs to take place so users with access to the object see all the tracked field changes?
  • January 16, 2017
  • Like
  • 0
I am trying to create an email alert that sends to users defined in the opportunity team of a quote.  When i set the recipients, selecting direct users or a user field on the rebate works fine, but when selecting users from the opportunity team list, it does not send.  screenshot:
User-added image
The 'Revvy Quote Owner' works, but the Opportunity team members do not.  Any idea what might be causing this?
Thanks.
  • January 09, 2017
  • Like
  • 0
I am working with an environment that is set to PST and had scheduled jobs for 11AM/11PM daily.  After the time change, it now appears to be running at 10AM/10PM daily even though the job is still showing 11AM/11PM in the scheduled jobs page.  Does salesforce not automatically adjust upon daylight savings time? The company time is set to PST under Company Profile -> Company Information.
Thanks.
  • November 08, 2016
  • Like
  • 0
I am having an issue with a permission to an object for a certain user.  They should only be able to view the objects that they created.  The OWD is set to private and his profile does not have any access to this particular object.  I went through all of the permission sets, but there are a lot, so I am not certain where it is allowing them to view all of the objects in that object's own tab under view all.

Is there a better or easier way to troubleshoot and determine where they are getting the access to view all of the data of the particular object? They can view ones that the admin created.

Thanks!
  • August 19, 2016
  • Like
  • 1
when running a test in my test class I am seeing this error: 

INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Z102 [Payment__c]

but Z102 is the default value. In fact I don't even set the value it is automatically set so I know its not a typo or anything, I don't even reference the Payment__c in the test class.  How could this be? Any idea what's going on here?
Not sure why this isn't working, but is it not enough to have get;set; on a list of objects as a getter to use them in a repeat function with a visualforce page?
public List<Custom_Quote_Item__c> quoteItemList {get;set;}

then in the visualforce page:
<apex:repeat value="{!quoteItemList}" var="qi">

I know the list has about 10 items in it but nothing is executing inside the repeat.

I also tried creating a getter function:
public List<Custom_Quote_Item__c> getQuoteItems() {
        return quoteItemList;
    }
but that isn't working either.  I am confused why this isn't working because i am using repeat on a number of lists in my class which all seem to work find but this one isn't.  If anyone has any input I would greatly appreciate it!

Thanks
I use the following in a visualforce page:
{!IF(qis.QISLIndent == true, '&nbsp;' , null )} 
and the output when true shows up as &#160;

How do I fix this?
I am having a bit of trouble creating a flag to determine if a line item is in the same group as the item before it.  So I want to create a variable to determine if the item number on a line item is the same as the previous item in the repeat section.  for example
variable itemID = 0;
repeat var = qi{
if(qi.itemID == itemID) indent output text;
else
itemID = qi.itemID
}

of course it would be in apex not java but this is what I need to accomplish.  Can i create a variable in the apex or would it be best to have a variable in the controller that holds the value and reassign it?
  • April 19, 2016
  • Like
  • 0
I am currently migrating to a new salesforce buildout using the exported data from an old environment.  I want to upload the contacts by themselves but can't seem to figure out a good way to do this short of manually putting together an excel spreadsheet where all the contact information is matched with an account, but this would take a long time with all the data.  Previously I have used data loader , but this environment doesn't have API access so that isn't an option.  Is there an easy way using the data import wizard to import just contacts?
  • March 23, 2016
  • Like
  • 0
I am trying to assign a value to a custom setting with an automated daily data pull from a site, which all works fine but I am having trouble assigning the actual custom setting variable to the new value.  Is this not possible?  The code is below, and the part that matters is the last few lines of code which try to assign a new value to a custom settings variable.
 
global class ALVIScheduledCurrencyDataPull Implements Schedulable
{
    global void execute(SchedulableContext sc)
    {
        pullCADRatio();
    }
    
    @future(callout=true)
    public static void pullCADRatio()
    {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('http://apilayer.net/api/live?access_key=getoffmykey');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        system.debug(response.getStatusCode());
        system.debug(response.getBody());
        
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) 
        {
            // Deserialize the JSON string into collections of primitive data types.
            
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            system.debug(results);
            // Cast the values in the 'quotes' key as a list
            Map<String,Object> ob = (Map<String, Object>)results.get('quotes');
            system.debug('quotes object: ' + ob);
            
            Object tst = ob.get('USDCAD');
            system.debug(tst);
            Decimal cadCon = (Decimal)tst;
            system.debug(cadCon);
			
            List<Currency_Conversion_Ratios__c> cadList = new List<Currency_Conversion_Ratios__c>();
            //pull the conversion ratio object, assign value from site, update into SFDC  
            Currency_Conversion_Ratios__c CADconvert = 
                Currency_Conversion_Ratios__c.getOrgDefaults();

            CADconvert.CAD__c = cadCon;
            cadList.add(CADconvert);
            update cadList; 

        }
    }
}



 
  • March 11, 2016
  • Like
  • 0
I am wondering how i would approach creating something similar to the 'PDF Viewer' that is inherent in salesforce when you view a quote with the buttons on the bottom while being able to view the PDF.  I have a PDF being generated from a button on the opportunity page but i want the option for the user to save that pdf and/or email that pdf out to a customer.  I assume if i am generating a pdf I cannot use any type of command button, so I would either have to have separate buttons on the opportunity page to do this each seperately, or which I would prefer, have a controller that displays a pdf document inside of a form and allow buttons to display as well.  
Would that be the correct approach? is there a way to display a pdf document inside of an apex form easily?
  • March 09, 2016
  • Like
  • 1
I am wondering how to assign an object to be placed into a related list of an object.  I am trying to add products to the product list in an opportunity from a visualforce page but im not sure how to add this object in the controller to the opportunity related list 'Products'.  How would I add a product I have to the related list of a specific opportunity?
  • March 07, 2016
  • Like
  • 0
I am having an issue with a permission to an object for a certain user.  They should only be able to view the objects that they created.  The OWD is set to private and his profile does not have any access to this particular object.  I went through all of the permission sets, but there are a lot, so I am not certain where it is allowing them to view all of the objects in that object's own tab under view all.

Is there a better or easier way to troubleshoot and determine where they are getting the access to view all of the data of the particular object? They can view ones that the admin created.

Thanks!
  • August 19, 2016
  • Like
  • 1
I am wondering how i would approach creating something similar to the 'PDF Viewer' that is inherent in salesforce when you view a quote with the buttons on the bottom while being able to view the PDF.  I have a PDF being generated from a button on the opportunity page but i want the option for the user to save that pdf and/or email that pdf out to a customer.  I assume if i am generating a pdf I cannot use any type of command button, so I would either have to have separate buttons on the opportunity page to do this each seperately, or which I would prefer, have a controller that displays a pdf document inside of a form and allow buttons to display as well.  
Would that be the correct approach? is there a way to display a pdf document inside of an apex form easily?
  • March 09, 2016
  • Like
  • 1
I have this trigger below to pull out 4 users from my object Territories (ASD_Sales_Rep__c, PSD_Sales_Rep__c, Service_Sales_Rep__c, Switch_Sales_Rep__c, Transmission_Sales_Rep__c) and need to add those users in the AccountTeamMembers for the account.  How do you add accountteammembers to an account? i dont see the account team members field for accounts so not sure where to place these.

trigger acctTeamUpdate on Account (after update, after insert) {
    List<Account> accUpdateList = new List<Account>();
    AccountTeamMember[] newmembers = new AccountTeamMember[]{};
    
    for (Account a : Trigger.new)
    {
       Account acc = new Account();
       
        Territory__c t;
    
        try {                                                    // get the Territory record for the territory specified in the Account Record
            t = [SELECT ID, Name, ASD_Sales_Rep__c, PSD_Sales_Rep__c, Service_Sales_Rep__c, Switch_Sales_Rep__c, Transmission_Sales_Rep__c
                FROM Territory__c
                WHERE ID=:a.Territory__c LIMIT 1];
        }
        catch(exception ex){ 
            System.debug(' Failed Territory Record Retrieval');
        }

        AccountTeamMember addSalesRep=new AccountTeamMember();
        
        addSalesRep.AccountId=a.id;
        addSalesRep.UserId=t.ASD_Sales_Rep__c.uid;
        newmembers.add(addSalesRep);
        
        acc.Id = a.Id;
        accUpdateList.add(acc);

    }
    
    try{
        update accUpdateList;
    }
    catch(exception ex)
            { 
                System.debug(' Failed Account Update');
            }
}
  • October 02, 2015
  • Like
  • 1
I have a custom object in which I have selected 20 fields to track. When changing these fields, it doesn't seem to add anything to the related list on the object page.
Any idea what would cause these not to show up or are there any type of additional configuration that needs to take place so users with access to the object see all the tracked field changes?
  • January 16, 2017
  • Like
  • 0
I am having an issue with a permission to an object for a certain user.  They should only be able to view the objects that they created.  The OWD is set to private and his profile does not have any access to this particular object.  I went through all of the permission sets, but there are a lot, so I am not certain where it is allowing them to view all of the objects in that object's own tab under view all.

Is there a better or easier way to troubleshoot and determine where they are getting the access to view all of the data of the particular object? They can view ones that the admin created.

Thanks!
  • August 19, 2016
  • Like
  • 1
Not sure why this isn't working, but is it not enough to have get;set; on a list of objects as a getter to use them in a repeat function with a visualforce page?
public List<Custom_Quote_Item__c> quoteItemList {get;set;}

then in the visualforce page:
<apex:repeat value="{!quoteItemList}" var="qi">

I know the list has about 10 items in it but nothing is executing inside the repeat.

I also tried creating a getter function:
public List<Custom_Quote_Item__c> getQuoteItems() {
        return quoteItemList;
    }
but that isn't working either.  I am confused why this isn't working because i am using repeat on a number of lists in my class which all seem to work find but this one isn't.  If anyone has any input I would greatly appreciate it!

Thanks
I am wondering how to assign an object to be placed into a related list of an object.  I am trying to add products to the product list in an opportunity from a visualforce page but im not sure how to add this object in the controller to the opportunity related list 'Products'.  How would I add a product I have to the related list of a specific opportunity?
  • March 07, 2016
  • Like
  • 0
I am wondering how to create an input field like you would see on any of the pre existing SFDC edit pages for the account "Account Name Lookup (new window)" with the magnifying glass logo to the right of it, on my own custom visualforce page.  I can get the field to come up using inputField but there is no wigit on the side to search through the existing accounts.  Any help here?
  • March 07, 2016
  • Like
  • 0
I have a custom visualforce Email Template and want to email it but as an attachment.  Is this possible to do or what would be my best approach?  I could just create a regular visual force page and render as pdf I know but wondering if I can salvage the EmailTemplate in any way and send it as an attachment.  Thoughts??
  • January 29, 2016
  • Like
  • 0
I am having issues refreshing a page when I click save on my visualforce page.  I want to keep the current url but when I try and pass the url from the controller it loses the reference to the timecard id in the url:
 
public PageReference save(){
PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
system.debug(pageRef);
pageRef.setRedirect(true);
return pageRef
}
and the logs show: 09:18:52:328 CODE_UNIT_FINISHED VF: /apex/TestAccountPage but the link I am using is /apex/TestAccountPage?timecardId={!timecard.id}
I have also tried to implement it in the visual force page which would be my preference using the onclick in the commandbutton:
onclick="window.location= ' /apex/TestAccountPage?timecardId={!timecard.id} ' "

but it also just goes to the /apex/testaccountpage when i click the button.  Any help?
 
  • January 08, 2016
  • Like
  • 0
I am wondering if there is an easy way to access the conversion rate from the Manage Currencies page.  We have multicurrency set up and I just want to access the conversion rate decimal.  for example I have a decimal and want to multiply it by the CAD conversion rate.  
Decimal numberToConvert = 100;
numberToConvert=ConversionRate*numberToConvert;

I see in the manage currencies the conversionrate field is .66.  How do I access that field variable in the visualforce page?
  • December 02, 2015
  • Like
  • 0
I am wondering how I can get the logs for an apex controller.  It seems to generate any other type ( visualforce page, apex trigger, etc) in the dev console whenever that piece of code is accessed or executed in the salesforce loadout and puts them in the logs tab in the console, but for the controller that I access from these types of triggers and pages do not generate logs here.  Even if i run a test that tests the controller I don't seem to find the logs.  How can I generate and find the logs that an apex controller spit out?

Thanks!
  • November 23, 2015
  • Like
  • 0
I am trying to take whoever the primary user is in an opportunity's contact roles and populate a Lookup(user) field with this person but need a little help.  This is what I have but i am missing some understanding of contactrole and user's id relationship.  How would I accomplish this?
 
trigger UpdateOpportunityContact on Opportunity (after update, after insert) {
    List<OpportunityContactRole> contactRoles = new List<OpportunityContactRole>();
    
    for( Opportunity acc : [ Select Id, (SELECT OpportunityId,IsPrimary,ContactId  FROM OpportunityContactRoles) FROM Opportunity ])
    {
        contactRoles.addALL(acc.OpportunityContactRoles);
    }
    for(Opportunity opp : trigger.new)
    {
    for(OpportunityContactRole role : contactRoles)
    {
        if(role.IsPrimary)
        {
            opp.Primary_Contact__c = new User(ContactId = role.ContactId);
            upsert opp.Primary_Contact__c;
        }
    }
    }

}

 
  • November 05, 2015
  • Like
  • 0
I am wondering if there is any extension that I might not be seeing in the soap api guide that would be the equivalent to list.contains so that I can check if an item already exists in a list.  Or is there a simple way to do this besides checking each item of the list everytime?

Thanks
  • November 03, 2015
  • Like
  • 0
I am having a small issue populating 2 fields in my custom button, everything else seems to work fine but the account field does not populate anything and I cannot populate a user in the account contact field.  comments by the problem areas. code:
 
/setup/ui/recordtypeselect.jsp?ent=01I3B0000008YRp&
retURL=%2F{!Opportunity.Id}&
save_new_url=%2Fa2C%2Fe%3F{!Opportunity.Name}
accid={!Opportunity.Id}&
CF00N3B000000OKFI={!Opportunity.Primary_Contact__c}&
CF00N3B000000OKFI_lkid={!Opportunity.Primary_Contact__c.UserId}&//not sure how to reference the user id here?
CF00N3B000000OKFz={!Opportunity.Name}&
CF00N3B000000OKFz_lkid={!Opportunity.Id}&
CF00N3B000000OKFB ={!Opportunity.Account}&//this field is left blank, but these references work in any other field i assign them to
CF00N3B000000OKFB_lkid={!Opportunity.AccountId}&
00N3B000000OKFR={!Today()+90}&
Name=Quote For {!Opportunity.Name}

and in fact i would rather have the primary user in the related list Contact Roles as the Account contact.  Any help is greatly appreciated!
  • November 01, 2015
  • Like
  • 0
Hi,
So I am trying to set up an opportunity split inside of a trigger (shown below).  I am having trouble getting the correct sales rep into the opportunity split.  I have an object in opportunity called territories which defines which user gets credit for what type of product, for example: territory__c.A_Sales_rep should get credit if the product (or quoteItem below) is of Sales_Division_c is A and territory__c.B_Sales_rep if it is a product of sales division B.  

So overall I just want to achieve the following: Get the sales division that the product is in, get the sales rep that owns that division, and apply an opportunity split.

Any help is appreciated, this has been driving me a little crazy!
trigger UpdateSplits on Opportunity(after update, after insert) 
{
    List<REVVY__MnQuoteItem__c> qItem = new List<REVVY__MnQuoteItem__c>();

    for( Opportunity acc : [ Select Id, (Select Id,Name,REVVY__Price__c FROM REVVY__QuoteItems__r) FROM Opportunity where Id IN: trigger.new ])
    {
        qItem.addALL( acc.REVVY__QuoteItems__r );
    }
    
    List<OpportunitySplit> oppSplitList = new List<OpportunitySplit>();
    
    for(REVVY__MnQuoteItem__c item : qItem)
    {
        //find sales division that gets credit for the quote item == item.Sales_Division__c
        
        oppSplitList.add(new OpportunitySplit(
            OpportunityId = [ Select Id FROM Opportunity where Id IN: trigger.new ]
            , UserId = ???? );
        
        //find rep that gets credit
    
    } 
}

 
  • October 20, 2015
  • Like
  • 0
I am a little unsure on how to go about doing this because my understanding of related lists on an object isn't completely there yet.  I want to create a trigger that accesses data in an opportunity.  The data I need to access is a related list of custom objects, the related list is called Quoted Products.  Would I access it something like:
trigger UpdateSplits on Opportunity (before update, before insert) 
{
    Set<id> eventIds = new Set<Id>();
    for (Opportunity opp : Trigger.new) {
        eventIds.add(opp.Quoted_Products__c);
    }
    Map<Id, Event__c> eventMap = new Map<id,Quoted_Products__c>([SELECT id, Name, 
                                                                       (SELECT Id, Name 
                                                                        FROM Products)
                                                       FROM Quoted_Products__c
                                                       WHERE id in :eventIds]);
//use data for other things 
}



Also, where are the related lists defined? I cannot find the related list in objects or labels.  This particular related list is a list of products but I would like to know where this list is named and setup.  Any help is greatly appreciated.
  • October 20, 2015
  • Like
  • 0