• Andrew Likens
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 17
    Replies
Hello!

I have a future method that I want to pass account IDs and batch process them into a Set instead of passing one record at a time. I'm also calling to a web service that accepts JSON so do I have to serialize the set of account IDs in order for my web service to accept my set of account IDs? My code is below of what I'm trying to do but I get a 500 error.

Future method:
 
global class AccountUpsert{
  @future (callout=true)
   public static void AccountUpdate(Set<Id> accountId) {
     List<Account> accountList = [SELECT Id FROM Account WHERE Id IN :accountId];
     String str = JSON.serialize(accountList);
     Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://qa-svc01.salesforce.signzoneinc.com:49832/v1/Account/Updated');
request.setMethod('POST');
request.setBody(str);
request.setHeader('Content-Type', 'application/json');
request.setHeader('Content-Length', request.getBody());
request.setTimeout(120000);
HttpResponse response = http.send(request);
}
}

Account Trigger:
 
trigger AccountInsert on Account (before update, after update) {
    
    Set<Id> ids = new Set<Id>();

    for (Account acc : Trigger.new) {
        
            if (acc.Account_Status__c == 'Customer'
                && (System.IsBatch() == false && System.IsFuture() == false)
               ) 
            {
                ids.add(acc.Id);
                AccountUpsert.AccountUpdate(ids);
            } 
    }
}

Web Service:

User-added image

Any help is greatly appreciated!!​
Hello,

I am having trouble covering the if clauses in my trigger. The 'toAddresses' in my if statements are not being covered by my test class. Any help is greatly appreciated!

My trigger:
 
trigger SendEmailCompletedVirtual on Virtual_Request__c (after insert, after update) {
    
    List<Virtual_Request__c> completedVirtuals = [SELECT Salesperson__c, Inside_Salesperson__c, Virtual_Request_Status__c, Virtual_Request_Opportunity_Number__c,
                                                  Account__c, Account_Number__c, Owner.Name, Virtual_Request_Opp_Number__c, Total_Amount__c, Territory__c 
                                                  FROM Virtual_Request__c WHERE Virtual_Request_Status__c = 'Completed'];
    
    For (Virtual_Request__c vr : completedVirtuals) {
        
        String[] toAddresses = new String[] {'email@email.com'};
        
        if (vr.Salesperson__c == 'John Andersen') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-andersen@signzoneinc.com', 's-jones@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Javier LaFontaine') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-lafontaine@signzoneinc.com', 's-jones@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Wade Newbauer') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'w-newbauer@signzoneinc.com', 'n-linn@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Dan Donnellan') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'd-donnellan@signzoneinc.com', 'n-linn@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Scott Favreau') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 's-favreau@signzoneinc.com', 'd-kreidermacher@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Tom Jungroth') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-jungroth@signzoneinc.com', 'd-kreidermacher@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Rosemary Dingmann') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'r-dingmann@signzoneinc.com', 't-broberg@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Teresa Johnson') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-johnson@signzoneinc.com', 'h-ferguson@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Mike Hutchinson') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'm-hutchinson@signzoneinc.com', 'k-wagner@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Marty Walsh') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'm-walsh@signzoneinc.com', 'h-ferguson@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Mark Thieleke') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'm-thieleke@signzoneinc.com', 'r-lester@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Bo Turner') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'b-turner@signzoneinc.com', 'r-lester@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Jeff Isberner') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-isberner@signzoneinc.com', 'h-ferguson@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Ernie Quintana') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'e-quintana@signzoneinc.com', 'c-stokes@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'W1 Lonestar North') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'p-langdon@signzoneinc.com', 'w-ferguson@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Monte Echelle') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'm-echelle@signzoneinc.com', 't-seguin@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Jeff List') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-list@signzoneinc.com', 't-seguin@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Jon Pierce') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-pierce@signzoneinc.com', 'k-nevala@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Jon Henrickson') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-henrickson@signzoneinc.com', 'r-stassen@signzoneinc.com'};
        }
        
        if (vr.Salesperson__c == 'Michael Duke') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'm-duke@signzoneinc.com', 'r-stassen@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'Canada') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-nevala@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'DLE3467') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com', 'c-stokes@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'C05353') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com', 'k-wagner@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'DLE7388') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com', 'w-ferguson@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H13 Allegro Display & Graphics') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H14 American Sol For Bus') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H15 WorkflowOne(Standard Register)') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'r-cordes@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'C10516') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'r-cordes@signzoneinc.com', 'k-nevala@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H17 Innerworkings') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 's-garvalia@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H18 Spicers') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'd-holleman@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H19 Office Depot') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-adams@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'DNM4901' || vr.Account_Number__c == 'C20894') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'd-twedt@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'C11504') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-adams@signzoneinc.com', 't-broberg@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'C06272') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'r-cordes@signzoneinc.com', 't-seguin@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'H3 Staples') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-freundschuh@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'C07251') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-freundschuh@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'GIL2010') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-adams@signzoneinc.com', 'k-wagner@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == '2220564') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-adams@signzoneinc.com', 'k-wagner@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'SF-123261') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-adams@signzoneinc.com', 'd-kreidermacher@signzoneinc.com'};
        }
        
        if (vr.Account_Number__c == 'DCC4211') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'r-cordes@signzoneinc.com', 'd-twedt@signzoneinc.com'};
        }
                       
        if (vr.Account_Number__c == '2117225') {
            toAddresses = new String[] {'alikens@signzoneinc.com','k-nevala@signzoneinc.com'};
        }
        
        //KD Signs House Account
        if (vr.Account_Number__c == 'SF-181384') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-walsh@signzoneinc.com'};
        }
        
        //Riley Promotions House Account
        if (vr.Account_Number__c == 'SF-181385') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-walsh@signzoneinc.com'};
        }
        
        //Pfingsten Partners House Account
        if (vr.Account_Number__c == 'SF-184562') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-walsh@signzoneinc.com'};
        }
        
        //Creative Marketing Concepts House Account
        if (vr.Account_Number__c == 'CMC4101') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'p-langdon@signzoneinc.com'};
        }
        
        //Cimpress dba Vistaprint House Account
        if (vr.Account_Number__c == 'SF-118315') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-olson@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'International Territory') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'k-walsh@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC Canada') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-vanderwerf@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC House') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'a-ziskin@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC International') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'p-king@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC Jodi Accounts') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'j-lindstrom@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC North') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 't-vanderwerf@signzoneinc.com'};
        }
        
        if (vr.Territory__c == 'VC South') {
            toAddresses = new String[] {'alikens@signzoneinc.com', 'p-king@signzoneinc.com'};
        }
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('donotreply@signzoneinc.com');
        mail.setSenderDisplayName('Creative Services Dept');
        mail.setSubject('A Virtual Request Has Been Completed');
        String body = '<p style="font-family:Arial"><b>A request for a Virtual Sample was submitted to Creative Services. Creative Services has completed the sample. Below is a link to go directly to the Virtual Request opportunity.</b></p>';
        body += '<p style="font-family:Arial"><b>If revisions are needed, please make notes in the personalization box on the opportunity product and click Send <i>Virtual Request Revision Email button</i>.</b></p>';
        body += '<p style="font-family:Arial"><b>If no changes are needed, no further action is required.</b></p>';
        body += '<br><p style="font-family:Arial"><a href=https://test.salesforce.com/'+vr.Virtual_Request_Opportunity_Number__c+'>https://test.salesforce.com/'+vr.Virtual_Request_Opportunity_Number__c+'</a></p>';
        body += '<br><br><p style="font-family:Arial">Account: ' + vr.Account__c;
        body += '<br><p style="font-family:Arial">Account Number: ' + vr.Account_Number__c;
        body += '<br><p style="font-family:Arial">Created By: ' + vr.Owner.Name;
        body += '<br><p style="font-family:Arial">Opportunity Number: ' + vr.Virtual_Request_Opp_Number__c;
        body += '<br><p style="font-family:Arial">Amount: ' + '$' + vr.Total_Amount__c;
        mail.setHtmlBody(body);
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
    }
}

My Test Class:
 
@isTest
public class TestSendEmailCompletedVirtual {
    static testMethod void insertNewVirtual() {
        
        List<Virtual_Request__c> vr = new List<Virtual_Request__c>{new Virtual_Request__c
            (OwnerID = '005i0000001EYnX',
            Virtual_Request_Status__c = 'Not Started')};
            
        insert vr;
       
        List<Virtual_Request__c> vr1 = new List<Virtual_Request__c>{[SELECT Id, Virtual_Request_Status__c, Territory__c, Account_Number__c, Salesperson__c FROM Virtual_Request__c
                                                                    WHERE Id In:vr]};
                                                                    
        for (Virtual_Request__c vr2 : vr1) {
            vr2.Virtual_Request_Status__c = 'Completed';
            
            String[] toAddresses = new String[] {'email@email.com'};
                
                if(vr2.Salesperson__c == 'John Andersen') {
                    toAddresses = new String[] {'test0@signzoneinc.com'};
                }
            
                if(vr2.Territory__c == 'W1 Lonestar North') {
                    toAddresses = new String[] {'test1@signzoneinc.com'};
                }
            
                if(vr2.Account_Number__c == '12345') {
                    toAddresses = new String[] {'test2@signzoneinc.com'};
                }
            
                if(vr2.Salesperson__c != 'John Andersen') {
                    toAddresses = new String[] {'test3@signzoneinc.com'};
                }
            
                if(vr2.Territory__c != 'W1 Lonestar North') {
                    toAddresses = new String[] {'test4@signzoneinc.com'};
                }
            
                if(vr2.Account_Number__c != '12345') {
                    toAddresses = new String[] {'test5@signzoneinc.com'};
                }
                        
                Messaging.SingleEmailMessage mailtest = new Messaging.SingleEmailMessage(); 
                    mailtest.setToAddresses(toAddresses);
                    mailtest.setReplyTo('dnr@signzoneinc.com');
                    mailtest.setSenderDisplayName('Test Dept');
                    mailtest.setSubject('test email');
                    mailtest.setHtmlBody('body');
        
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mailtest});
        }
        update vr1;
    }
}

 
Hello,

I'm looking to create a button that when clicked, will create an opportunity line item on a custom object related to the opportunity as a related list. Very similar to syncing opp line items and quote line items. My custom object is called "Product__c" and has fields Quantity, Description, Amount, etc., same as opp line items. The Product__c object is a child of "Virtual_Request__C" object that has a lookup to the opportunity. I want the Product__c fields to match the standard opp line item fields.

I'm unsure if a trigger is used here or apex code because I want the action to occur from a button click. Any help is greatly appreciated!
Hello,

I am trying to write a unit test for this class that makes a POST REST API callout. I also create a custom object based on the response I'm returning. I get 65%, but can't figure out how to get more code coverage. Any help is greatly appreciated!

Class:
global class AccountUpsert{
  @future (callout=true)
   public static void AccountUpdate(Id accountId) {
     //Construct HTTP request and response
     //Http request method,Endpoint and setBody
     String body = '["accounts"]';
     Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://dev-svc01.salesforce.signzoneinc.com:49831/v1/Account/' + accountId + '/Updated');
request.setMethod('POST');
request.setHeader('Content-Type', 'text/json');
request.setHeader('Content-Length', '0');
request.setBody(body);
request.setTimeout(120000);
HttpResponse response = http.send(request);

// Parse the JSON response
if (response.getStatusCode() > 399 || response == null) {
    System.debug('Status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
    
    Error_Object__c[] errobj = new List<Error_Object__c>();
    //Error_Object__c[] errobj = [SELECT Account__c, Account__r.Nav_Unique_ID__c FROM Error_Object__c];
    
    //Create new record for failed messages. Error_Object is a holding queue for failed messages.
    Error_Object__c newErrorObject = new Error_Object__c();
    newErrorObject.Account__c = accountId;
    errobj.add(newErrorObject);
    try {
        upsert errobj;
    } 
    catch (DmlException e) {
        System.debug(e.getMessage());
    }
}
       else if (response.getStatusCode() >= 200 && response.getStatusCode() < 398) {
           Error_Object__c[] errobj1 = [SELECT Account__c, Account__r.Nav_Unique_ID__c FROM Error_Object__c WHERE Account__c = :accountId];
           if (errobj1.size() > 0) {
           delete errobj1;
           }
       }
 }
}
HttpCalloutMockClass:
@isTest
global class MakeMockHttpResponse implements HttpCalloutMock {
    
    //implement HTTPResponse Method
    global HTTPResponse respond(HTTPRequest request) {
        System.assertEquals('POST', request.GetMethod());
        
        //create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'text/json');
        response.setStatusCode(200);
        return response;
    }
}

Test Class I have so far:
 
@isTest
private class AccountUpsertTest {
    @isTest static void testCallout() {
        Test.setMock(HttpCalloutMock.Class, new MakeMockHttpResponse());
        
        Test.startTest();
        AccountUpsert.AccountUpdate('0015500000LVMRJ');
        Test.stopTest();
    }
    
    @isTest static void ErrorTest() {
        Test.startTest();
        Error_Object__c newErrorObject = new Error_Object__c();
        newErrorObject.Account__c = '0015500000LWoGS';
        newErrorObject.OwnerId = '005i0000001EYnX';
        try {
        upsert newErrorObject;
        }
        catch (DmlException e) {
           System.debug(e.getMessage());
        }
        newErrorObject = [SELECT Id, Account__c FROM Error_Object__c WHERE Id = :newErrorObject.Id];
        System.assertEquals('0015500000LWoGS', newErrorObject.Account__c);
        Test.stopTest();
    }
}

 
I have a method that is setup to make an @future call on the account and contact. However, I have a third-party tool that makes updates to the opportunity. Whenever this third-party tool makes an update or a user creates an opportunity, it calls my @future account method setup. Why would that be? Our goal is not to call my method at all when creating/updating an opportunity because now we're running into the "too many future calls:51" error because the third-party tool does batch updates to the opportunity. I know there's a lookup relationship with account and opportunity, but that can't be the case here. Any insight would be greatly appreciated!
My org is trying to connect to a third-party application for CTI integration. However, my org has a private sharing model implemented. To get the features we want for the third-party application, we have to make users a 'System Admin' in our org, which is obviously not ideal. We have tested that making users a system admin is the only way to get the features we need. Our theory is our private sharing model is the cause of the third-party's API into Salesforce is not recognizing sharing rules. We contacted the developers for the third-party application and they advised we contact Salesforce support because they are just using Salesforce's API. Then, Salesforce support suggested I post on the developer forum. The third-party application is called CRMLink and they integrate with Salesforce for CTI. Any insight on effects of private sharing model and Salesforce's API would be greatly appreciated!
Here are my requirements:

1. I have accounts in a 'Potential Customer' picklist value for one of our custom fields on the account "Account_Status__c." When that value is changed from "Potential Customer" to "Customer", I want to invoke a method "ContactUpsert.ContactUpdate(con.Id)." However, I ONLY want to invoke that method when Account_Status__c is "Customer" and a field on the contact Contact_Status__c is "Contact." Otherwise, all related contacts to an account in the "Potential Customer" status should be static. Once that account is changed to "Customer" it should do an UPDATE to all related contacts. It can be any update to the contacts as long as it's an update. Our internal API triggers when an object is updated in Salesforce. I'm a developer newbie so any help would be greatly appreciated!! Much thanks in advance!!
I am a complete newbie to API REST services in Salesforce. I have created the connected app in my sandbox and my manager has setup the connections in that with our web services. Now, I'm just looking to create an API REST (POST) to our endpoint URL.

I have taken a look at the REST API documentation, but like I said I'm a newbie so it's all a little foreign to me still.

Please help!!
I'm looking for a solution to replace a pricing table written in JavaScript on a custom home page component. With the Summer 15' release, JS on a home page component is no longer executionable, but my company got an extension to still use it toward the end of this year. I've seeked out technical advice and was told rewriting the "Add Products" button in visualforce would be the solution to go with, but it's VERY expensive to have a developer rewrite it in visualforce. Are there any other options besides visualforce that could display a table on the multiline.jsp page? The data in the table is data already stored in my salesforce instance so it's doing a soql lookup. Thanks!

User-added image
My org has exceeded our API request limit so now my users cannot create or edit any records. This is obviously a huge pain point.  Is there a way to manually recycle our API calls back to 0? Or do we have to wait the 24 hour period for them to automatically recycle?
I would like to create a list view that shows all opportunities that have synced quotes with them and be able to select of all them in the list and unsync them using a custom button using java code. Thank you!
I would like to create a list view that shows all opportunities that have synced quotes with them and be able to select of all them in the list and unsync them using a custom button using java code. Thank you!
Hello!

I have a future method that I want to pass account IDs and batch process them into a Set instead of passing one record at a time. I'm also calling to a web service that accepts JSON so do I have to serialize the set of account IDs in order for my web service to accept my set of account IDs? My code is below of what I'm trying to do but I get a 500 error.

Future method:
 
global class AccountUpsert{
  @future (callout=true)
   public static void AccountUpdate(Set<Id> accountId) {
     List<Account> accountList = [SELECT Id FROM Account WHERE Id IN :accountId];
     String str = JSON.serialize(accountList);
     Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://qa-svc01.salesforce.signzoneinc.com:49832/v1/Account/Updated');
request.setMethod('POST');
request.setBody(str);
request.setHeader('Content-Type', 'application/json');
request.setHeader('Content-Length', request.getBody());
request.setTimeout(120000);
HttpResponse response = http.send(request);
}
}

Account Trigger:
 
trigger AccountInsert on Account (before update, after update) {
    
    Set<Id> ids = new Set<Id>();

    for (Account acc : Trigger.new) {
        
            if (acc.Account_Status__c == 'Customer'
                && (System.IsBatch() == false && System.IsFuture() == false)
               ) 
            {
                ids.add(acc.Id);
                AccountUpsert.AccountUpdate(ids);
            } 
    }
}

Web Service:

User-added image

Any help is greatly appreciated!!​
Hello,

I'm looking to create a button that when clicked, will create an opportunity line item on a custom object related to the opportunity as a related list. Very similar to syncing opp line items and quote line items. My custom object is called "Product__c" and has fields Quantity, Description, Amount, etc., same as opp line items. The Product__c object is a child of "Virtual_Request__C" object that has a lookup to the opportunity. I want the Product__c fields to match the standard opp line item fields.

I'm unsure if a trigger is used here or apex code because I want the action to occur from a button click. Any help is greatly appreciated!
I have a flow that collects some user inputs and then is expected to update an Opportunity's stage to Closed Won.
The flow correctly updates all other updated fields on the Opportunity but does not modify the Stage Name.  For the Stage Name value I'm using the Picklist option.

Here is a screen shot of the assignment component:
Flow Opportunity Assignment Screen
 
  • January 31, 2017
  • Like
  • 0
I have a method that is setup to make an @future call on the account and contact. However, I have a third-party tool that makes updates to the opportunity. Whenever this third-party tool makes an update or a user creates an opportunity, it calls my @future account method setup. Why would that be? Our goal is not to call my method at all when creating/updating an opportunity because now we're running into the "too many future calls:51" error because the third-party tool does batch updates to the opportunity. I know there's a lookup relationship with account and opportunity, but that can't be the case here. Any insight would be greatly appreciated!
Here are my requirements:

1. I have accounts in a 'Potential Customer' picklist value for one of our custom fields on the account "Account_Status__c." When that value is changed from "Potential Customer" to "Customer", I want to invoke a method "ContactUpsert.ContactUpdate(con.Id)." However, I ONLY want to invoke that method when Account_Status__c is "Customer" and a field on the contact Contact_Status__c is "Contact." Otherwise, all related contacts to an account in the "Potential Customer" status should be static. Once that account is changed to "Customer" it should do an UPDATE to all related contacts. It can be any update to the contacts as long as it's an update. Our internal API triggers when an object is updated in Salesforce. I'm a developer newbie so any help would be greatly appreciated!! Much thanks in advance!!

Hello,

 

I would like to calculate the total amount of all child opportunities associated with the parent contact.

 

If a contact record has 2 opportunies, one with an amount of $20 and one with an amount of $50, i would like the contact record to have a field reflect the total of $50.

 

Below is the code i have so far.

------------------- 

trigger TestBed on Opportunity (after insert, after update)

{

 

 

//The list returns all the name of the contacts and the opportunity id and opportunity amount associated with that

contact

List<Contact> contax = [SELECT Contact.Name, (Select Opportunity.Id, Opportunity.Amount From Contact.Opportunities) From Contact Where Contact.AccountId != Null];

 

 

 

// Loop through the contacts and update their Opportunity Total field.

 for(Contact c : contax)

{

c.c_Opportunity_Total__c = contax.size();

}

 

// Update the database

 update contax;

 

 

 

 

}

---------------------

 

I would think it would be as easy as summing up the Opportunity.Amount.

 

LIke

 

c.c_Opportunity_Total__c = Sum(contax.Opportunity.Amount)

 

But that is not possible in this environment. Apparently the query fields associated with the list cannot be referenced. Or can they?

 

My questions are:

 

1.) With the above code, how can i reference the SOQL field Opportunity.Amount, and sum the total results of that query's findings for that field? Then add that total to the Contact record.

 

2.) Where can i find information about how to use math methods with SOQL?

 

Thanks so much for your help, so far i've spent hours trying to research this on my own with no luck. Newbie here.