• Keith Stephens 18
  • NEWBIE
  • 75 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 42
    Questions
  • 45
    Replies
Hello All,
I hope someone out here can help me, I am wanting to send emails out using sendgrid, I have created my sendgrid API Key, I have added the endpoint to SF remote settings "https://api.sendgrid.com/v3/mail/send".
And this works all fine in our sandbox, but now that it is in our production environment I seem to be getting an "16:46:10:021 EXCEPTION_THROWN [30]|System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://api.sendgrid.com/v3/mail/send".

I have verified my code in our sandbox and production environments are they are the same code.
Is there something else I might be missing?
Thanks for any help,
Keith.
Hello All,
I am in need to find a way to search Saleforce Database for Field or objects that were created but never used and there is no data in them.
So if you were to selct from these tables and fields it would be null.

Thansk,
Keith.
Hello All,
I hope someone can help me to format my JSON string This is what I have.
String tmpSetBody = '{\"personalizations\":[{\"to\":[{\"email\":\"'+recipient+'\",\"name\":\"'+recipient+'\"}],\"subject\":\"TestTestTest '+emailSubject + ' ' + candidate+'\"}],\"from\":{\"email\":\"support@email.com\",\"name\":\"Support\"},\"reply_to\":{\"email\":\"support@email.com\",\"name\":\"support\"},\"content\":[{\"type\":\"text/plain\",\"value\":\"'+body+'"\"}]})';
This is the result when using the system.debug and the development console:
tmpSetBody= {"personalizations":[{"to":[{"email":"myemail@mail.com","name":"First Name"}],"subject":"TestTestTest Modify existing card:  123"}],"from":{"email":"support@email.com","name":"Support"},"reply_to":{"email":"support@Email.com","name":"support"},"content":[{"type":"text/plain","value":"Modify  card: 123 Card Limit: 550.00

And this is how it should look:
tmpSetBody2= {"personalizations":[{"to":[{"email":"myemail@glofin.com","name":"support"}],"subject":"TestTestTest Modify existing card:  123"}],"from":{"email":"support@email.com","name":"support"},"reply_to":{"email":"support@email.com","name":"support"},"content":[{"type":
"text/plain","value":"Modify  card: 123 Card Limit: 550.00"}]})

It seems I am missing the ending brackets and quote, but everything I have tried does not seem to work.
Thanks,
Keith.
 
Hello All,
I think I need to code your own HTTP Post Request, formatted as JSON.
In order to call SendGrids email API's from my Salesforce Class, but I do not know how to do this.
Can anyone help me with the code that will do this?  I think it would be something similar to this:
string strUsername = 'testusername';
        string strPwd = 'testpwd';

        Http m_http = new Http();
        HttpRequest req = new HttpRequest();
        
            
        req.setEndpoint('"https://api.sendgrid.com/v3/mail/send');
        req.setHeader('Content-Type: application/json'); 
        req.setHeader('Authorization: Bearer SendGridAPIKEY');          
        req.setMethod('POST');
        req.setBody(content);
        
        httpResponse response = m_http.send(req);
Thanks,
Keith.
 
Hello All,
I am trying to use sendgrid-apex https://github.com/sendgrid/sendgrid-apex to send out vast emails that the Salesforce Email object does not allow.
I have followed there instructions but I am getting an error. SendGridException:[]: Script-thrown exception
The login credz for sendgrid are valid in that we use them in other apps.  And the variables I am using are all string variables.
Also I this code is in a trigger.
System.Debug('before creating sendgrid object');
         SendGrid sendgrid = new SendGrid('username', 'Password');
         SendGrid.email email = new SendGrid.Email();
         email.addTo('me@my.com');
         email.setFrom('me@bar.com');
         email.setSubject(emailSubject + ' ' + candidate);   
         email.setText(plainBody);
        
         System.debug('after send');

         //string response = sendgrid.send(email);
         //SendGrid.SendGridResponse response = sendgrid.send(email);
         //System.Debug('Response= '+response);
         sendgrid.send(email);
I hope someone can help me out.
Thanks,
Keith.
 
Do I get a bug finders fee for finding a bug in Salesforce?

 
Hello all,
I believe this is a standard field and not a custom field, what I want to do is to be able to change "Case number" from an auto number to a text number in my sandbox, so I can import some cases and keep the same ID's.  When I import my cases because of the auto number my links to contacts, ect.. are broken.

I have read various articles and they say:
1. Click on Your Name | Setup | Build | Customize | Object Name | Fields
2. Click Edit next to the Auto-Number field you want to modify
3. Change the Display Format and Next Number you want to be displayed for your records. And click Save.
4. You will receive a pop-up with the following message: “This may result in duplicate number. Are you sure?”
5. Click OK.

But I do not see a way to edit the field type, nor what Display Format to use.
Thanks,
K
Hello,
Today I noticed that when I update a field in cases and then click the save button our trigger we have setup to update additional fields does not fire,  but if we edit a field in cases then tab off the field the trigger fires and executes just fine.
Hello All,
I just started getting this error when trying to update case records from my C# .net app.
I was not getting this error a week ago but now I am all of a sudden, it is the Sandbox for development, but nothing has changed in it.
Not to keen on the snow white theme.
 VALIDATION FORMULA "ATTORNEY_FRAUD_CHECK" INVALID (ORA-20001:
ORA-06512: AT "GRUMPY.SACCESS", LINE 833
ORA-01403: NO DATA FOUND
ORA-06512: AT "GRUMPY.CACCESS", LINE 2869
ORA-06512: AT "GRUMPY.CACCESS", LINE 2768
ORA-06512: AT LINE 1
SQLEXCEPTION WHILE EXECUTING PLSQL STATEMENT: {CALL CACCESS.CHECK_ENTITY_ACCESS_PROC_NCU(?,?,?,?,?,?)}(EXCLUDED, EXCLUDED, 0033000001C99QN, EXCLUDED, TRUE, FALSE))
 
Hello All,
I have a C# app that used CData objets to pass a query to Salesforce to retrieve data.
What I want to do is get all cases that have a lastmodifiedDate of Now() - 10 minutes, and this will be a job that gets executed every 5 minutes, so I can keep our sql server updated with the latest cases that have been modified.
The problem I am facing is that some of these lastmodifiedDates in Salesforce are 5 hours ahead of Now(), so if I pass in 11am as UTC for Salesforce my UTC time in C# will be 11-10min. = 10:40 so this value is used in my SOQL and thousands of records are returend because we got cases that have a lastmodifiedDate of 16:00pm or 4pm in the future. And my Timezone is EST.

Thanks,
Keith

 
Hello All,
Our Development environment is on Winter 18, and I had this onclick javascript code working yesterday 2/72018 and now today I am getting the javascript error of:
RequireScript Undefined.  Can anyone help me out.

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

var documentCode = 'ATTYFAX_001';
var userName = '{!$User.Username}';

var result = sforce.apex.execute("DocuSendPostCaseInfo", "PostCaseInfo", { CaseNumber: '{!Case.CaseNumber}', DocumentCode: documentCode, UserName: userName });

alert(result);

Thanks,
KS
Hello all,

I need to get/run this soql script from my .NET app, using CDATA ADO.NET components.
But my issue is my soql statment will not run in .NET or in the SOQL Workbench.


SELECT AccountBroker__c,Application_Date__c,Application_Manager__c,CaseNumber,Id FROM Case where LastModifiedDate >= Date.Today().addDays(-2)

Thanks,
KS
Hello All,
I hope someone can help me or point me in the right direction to solve this error I am getting.
This error is occuring on this line:
AggregateResult[] AARsAB  = [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
			FROM Account_Procedure_Rate__c where Main_Center__c IN: centerMap.keySet()  group by CPT_Code__c, Main_Center__c];

I think it is due to it's bringing back to many rows.
Would this line of code resolve such issue?
List<SObject> AARs= [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
		FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];

Sticking it into a list of sobject?  If so what is the difference between the two?
This only occures in our production environment since we do not keep our dev and qa upto date with this many records ect..
Thanks,
Keith.
Hello All,
I hope someone can help me or point me in the correct direction to solve this error I am getting.
This error is occuring with this line of code I have:
AggregateResult[] AARsA  = [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
			FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];

I think it is due to it's seems to be bringing back thousands of recs, over 5000.
If I were to do this:
List<SObject> AARs= [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
		FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];


Would it fix my issue?
I cannot reporduce this in DEV or QA because we do not have that many records in those environments, we just do not keep our environments up to date.
Thanks,
KS
Hello All,
Can someone tell me if my trigger is bulkified?
I have removed all of the SOQL statments out of the loop, but I don't know if that is all I have to do to bulkify my code.
trigger MostRecentCenter on Procedure__c (after insert, after update) {
   try{           
          if (TriggerSettings.areTriggersDisabled()) return;  
           Set<Id> procIds = new Set<Id>();
           Set<Id> caseIds = new Set<Id>();
		   List<Case> lstCase = new List<Case>();
               
               for(Procedure__c proc : Trigger.New)
               {                 
                   if(proc.CreatedDate != null) 
                   { 
                       procIds.add(proc.LastModifiedById);  
                       caseIds.add(proc.Case__c);                      
                   }                        
               }                        
               
              Map<string, Procedure__c> procMap = new map<string, Procedure__c> ( [SELECT CenterID__c, Center__c from Procedure__c 
               where LastModifiedById IN: procIds Order by CreatedDate Desc] );     

              Map<string, Case> caseMap = new map<string, Case> ( [SELECT Id, Most_Recent_Center__c FROM Case WHERE Id IN: caseIds] );  
                         
                 for(Procedure__c pd: trigger.new) 
                 {       
                     //system.debug(pd.id);

                    if(procMap.containsKey(pd.id)) 
                    {           
                      
                        //Id centerID = (Id)procMap.get(pd.id).Center__c;
                        //Case cs = (Case)[SELECT Id, Most_Recent_Center__c FROM Case WHERE Id = :pd.Case__c];
                        //cs.Most_Recent_Center__c = centerID;
						
                        //system.debug('pd.id = ' + pd.id);
                        //system.debug('caseMap = ' + caseMap);
                        //system.debug('pd.case = ' + pd.Case__c);
                        //system.debug('procmap.get = ' + procMap.get(pd.id).Center__c);

                        caseMap.get(pd.Case__c).Most_Recent_Center__c =(Id)procMap.get(pd.id).Center__c;                     
                        lstCase.add(caseMap.get(pd.Case__c));                      
                                                               
                    }       
                }
                   // system.debug('lstCase Size = ' + lstCase.size());
				if(lstCase.size()>0)
                    //system.debug('in size if');
					update lstCase;                
          
        
    }catch(Exception e){
       //Package suspended, uninstalled or expired, exit gracefully.
       System.debug('Error MostRecentCenter');
       system.debug(e.getMessage());
       
    }
    
}


Thanks,
KS
Hello,
I have the follwoing code being executed in a for loop and I want to remove it from the loop and bulkify it how would I do this?
A list, or a map? I preferer to use a map if possible.
 
Account_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Account_Procedure_Rate__c 
														 	 WHERE  CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId];
							proc.Amount_To_Pay__c = rate.Amount_To_Pay__c;
							proc.Procedure_Cost__c = rate.Procedure_Cost__c;



Thanks,
K
Hello All,
I have the follwoing code and I want to return the count of records.
trigger Pupdate on Procedure__c (before update, before insert) {

Map<Id,AggregateResult> cprCnt = new Map<id,AggregateResult>([SELECT Count(id) maxRates
 		FROM Center_Procedure_Rate__c group by CPT_Code__c, Center__c]);
		
		if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					//centerRateCount = 
					//	[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
					//	 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					//maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
					
					maxCtrRates = cprCnt.get(proc.Center__c, proc.CPT_Code__c);
					system.debug(maxCtrRates);
		}
}
In the code you can see I am doing it through Soql, but I need to have this bulkified.
we are not hiting our soql limtis.
Thansk,
K
 
Hello All,
I am new to Salesforce development, so I hope someone can help me.
I need to get this trigger bulkified, but I do not know how, this trigger was written by someone else who no longer works for the company.
trigger ProcedureRateUpdates on Procedure__c (before update, before insert) {
	// if triggers have been globally disabled via TriggerCustomSettings setting, then exit
	if (TriggerSettings.areTriggersDisabled()) return;
	
	List<AggregateResult> centerRateCount = null;
	List<AggregateResult> acctRateCount = null;
	Integer maxCtrRates = 0;
	Integer maxAcctRates = 0;
	Id centerId = null;
	Boolean isManualProcPricing = false;
	
	
	// Set<Id> procIds = trigger.newMap.keySet();
	// List<Procedure_c> procs = [SELECT Id,  FROM Procedure__c 
	//						   WHERE Id IN :procIds];
					   
	for (Procedure__c proc: trigger.new) {
		if (proc.Override_Procedure_Rate__c == false) {
			// get the Main Center ID for the current procedure
			try {
				centerId = [SELECT Main_Center__c FROM Center__c WHERE Id = :proc.Center__c][0].Main_Center__c;
			} catch (Exception e) {
				proc.addError('Unable to determine Main Center. Ensure that this procedure has a Center selected.');
				continue;
			}
			// determine if Manual Procedure Pricing checkbox is checked
			isManualProcPricing = [SELECT Manual_Procedure_Pricing__c FROM Main_Center__c WHERE Id = :centerId][0].Manual_Procedure_Pricing__c;
			if (isManualProcPricing == false) {
				// only process the costs if entering a new procedure or updating an existing one that has a blank amount and cost
				// or updating an existing one only if the Procedure Status is not 'OK to Pay' or 'Paid')
				if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					centerRateCount = 
						[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
						 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
						
					if (maxCtrRates == 0) {
						System.debug('proc.Center__c = ' + proc.Center__c);
						// no rates found in Center Procedure Rate object, so look at Account Procedure Rate object for rate
						acctRateCount = [SELECT COUNT(Id) maxRates FROM Account_Procedure_Rate__c 
							 			 WHERE CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId];
						maxAcctRates = acctRateCount[0].get('maxRates') == null ? 0 : (Integer)acctRateCount[0].get('maxRates');
						
						if (maxAcctRates == 0) { 
							proc.addError('No rates found for this procedure.');
						} else if (maxAcctRates == 1) {
							Account_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Account_Procedure_Rate__c 
														 	 WHERE  CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId];
							proc.Amount_To_Pay__c = rate.Amount_To_Pay__c;
							proc.Procedure_Cost__c = rate.Procedure_Cost__c;
						} else {
							proc.addError('More than one procedure rate for the main center was found.');
						}
					} else if (maxCtrRates == 1) {
						Center_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Center_Procedure_Rate__c 
														 WHERE  CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						proc.Amount_To_Pay__c = rate.Amount_To_Pay__c;
						proc.Procedure_Cost__c = rate.Procedure_Cost__c;
					} else {
						proc.addError('More than one procedure rate for the center was found.');
					}
				}
			}
		}
	} 
}



Thanks,
Keith.
How do I set this up?
Will this debugger work without a salesforce debugger license?
Do you need to set up a scratch org?

Thanks,
Keith.
Hello All,
I am having issues with I think escaping values into my soql statment. Here is what I have
String userEmail = UserInfo.getUserEmail(); 
system.debug(userEmail);


String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Attny_Phone_From_Contact__c,Attorney_Email_from_Contact__c,Attorney_Email__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Full_Name__c,\''userEmail'\', Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+limit+3';
system.debug(url);

Yes, I want to return the UserEmail this way, but I am getting an "Unexpected token 'url' error.
Thanks for the help or guidance.
Keith.
Hello All,
I need to be able to update an Azure database from Salesforce.  Mainly for Cases and Lawyers, when cases or lawyers get updated I need to update the Azure DB as well.
I have seen the examples that talk about Azure to Salesforce, but I have not seen anything talking about Salesforce to Azure.
I have looked at both the Salesforce WCF and RestAPI https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/
But again these go from Azure to Salesforce.

Is it possible to go the other way?  What would be the best approch to this as I have seen many differnt approches to connecting.
We don't want any syncing of data, just to make a .NET call when Salesforce records get updates ect.. to update our Azure DB.
Thanks,
K.
Hello All,
I hope someone out here can help me, I am wanting to send emails out using sendgrid, I have created my sendgrid API Key, I have added the endpoint to SF remote settings "https://api.sendgrid.com/v3/mail/send".
And this works all fine in our sandbox, but now that it is in our production environment I seem to be getting an "16:46:10:021 EXCEPTION_THROWN [30]|System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://api.sendgrid.com/v3/mail/send".

I have verified my code in our sandbox and production environments are they are the same code.
Is there something else I might be missing?
Thanks for any help,
Keith.
Hello All,
I am in need to find a way to search Saleforce Database for Field or objects that were created but never used and there is no data in them.
So if you were to selct from these tables and fields it would be null.

Thansk,
Keith.
Hello All,
I hope someone can help me to format my JSON string This is what I have.
String tmpSetBody = '{\"personalizations\":[{\"to\":[{\"email\":\"'+recipient+'\",\"name\":\"'+recipient+'\"}],\"subject\":\"TestTestTest '+emailSubject + ' ' + candidate+'\"}],\"from\":{\"email\":\"support@email.com\",\"name\":\"Support\"},\"reply_to\":{\"email\":\"support@email.com\",\"name\":\"support\"},\"content\":[{\"type\":\"text/plain\",\"value\":\"'+body+'"\"}]})';
This is the result when using the system.debug and the development console:
tmpSetBody= {"personalizations":[{"to":[{"email":"myemail@mail.com","name":"First Name"}],"subject":"TestTestTest Modify existing card:  123"}],"from":{"email":"support@email.com","name":"Support"},"reply_to":{"email":"support@Email.com","name":"support"},"content":[{"type":"text/plain","value":"Modify  card: 123 Card Limit: 550.00

And this is how it should look:
tmpSetBody2= {"personalizations":[{"to":[{"email":"myemail@glofin.com","name":"support"}],"subject":"TestTestTest Modify existing card:  123"}],"from":{"email":"support@email.com","name":"support"},"reply_to":{"email":"support@email.com","name":"support"},"content":[{"type":
"text/plain","value":"Modify  card: 123 Card Limit: 550.00"}]})

It seems I am missing the ending brackets and quote, but everything I have tried does not seem to work.
Thanks,
Keith.
 
Hello All,
I think I need to code your own HTTP Post Request, formatted as JSON.
In order to call SendGrids email API's from my Salesforce Class, but I do not know how to do this.
Can anyone help me with the code that will do this?  I think it would be something similar to this:
string strUsername = 'testusername';
        string strPwd = 'testpwd';

        Http m_http = new Http();
        HttpRequest req = new HttpRequest();
        
            
        req.setEndpoint('"https://api.sendgrid.com/v3/mail/send');
        req.setHeader('Content-Type: application/json'); 
        req.setHeader('Authorization: Bearer SendGridAPIKEY');          
        req.setMethod('POST');
        req.setBody(content);
        
        httpResponse response = m_http.send(req);
Thanks,
Keith.
 
Hello All,
I am trying to use sendgrid-apex https://github.com/sendgrid/sendgrid-apex to send out vast emails that the Salesforce Email object does not allow.
I have followed there instructions but I am getting an error. SendGridException:[]: Script-thrown exception
The login credz for sendgrid are valid in that we use them in other apps.  And the variables I am using are all string variables.
Also I this code is in a trigger.
System.Debug('before creating sendgrid object');
         SendGrid sendgrid = new SendGrid('username', 'Password');
         SendGrid.email email = new SendGrid.Email();
         email.addTo('me@my.com');
         email.setFrom('me@bar.com');
         email.setSubject(emailSubject + ' ' + candidate);   
         email.setText(plainBody);
        
         System.debug('after send');

         //string response = sendgrid.send(email);
         //SendGrid.SendGridResponse response = sendgrid.send(email);
         //System.Debug('Response= '+response);
         sendgrid.send(email);
I hope someone can help me out.
Thanks,
Keith.
 
Hi,

I have integrated salesforce with sendgrid, when I send bulk email from Salesforce via sendgrid user receiving list of toaddress emails.
how can every user receive only their toaddress.

Thanks 
Hello All,
I hope someone can help me or point me in the right direction to solve this error I am getting.
This error is occuring on this line:
AggregateResult[] AARsAB  = [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
			FROM Account_Procedure_Rate__c where Main_Center__c IN: centerMap.keySet()  group by CPT_Code__c, Main_Center__c];

I think it is due to it's bringing back to many rows.
Would this line of code resolve such issue?
List<SObject> AARs= [SELECT Count(id) maxRates, Main_Center__c,CPT_Code__c
		FROM Account_Procedure_Rate__c  group by CPT_Code__c, Main_Center__c];

Sticking it into a list of sobject?  If so what is the difference between the two?
This only occures in our production environment since we do not keep our dev and qa upto date with this many records ect..
Thanks,
Keith.
Hello All,
I have the follwoing code and I want to return the count of records.
trigger Pupdate on Procedure__c (before update, before insert) {

Map<Id,AggregateResult> cprCnt = new Map<id,AggregateResult>([SELECT Count(id) maxRates
 		FROM Center_Procedure_Rate__c group by CPT_Code__c, Center__c]);
		
		if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					//centerRateCount = 
					//	[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
					//	 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					//maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
					
					maxCtrRates = cprCnt.get(proc.Center__c, proc.CPT_Code__c);
					system.debug(maxCtrRates);
		}
}
In the code you can see I am doing it through Soql, but I need to have this bulkified.
we are not hiting our soql limtis.
Thansk,
K
 
Hello All,
I am new to Salesforce development, so I hope someone can help me.
I need to get this trigger bulkified, but I do not know how, this trigger was written by someone else who no longer works for the company.
trigger ProcedureRateUpdates on Procedure__c (before update, before insert) {
	// if triggers have been globally disabled via TriggerCustomSettings setting, then exit
	if (TriggerSettings.areTriggersDisabled()) return;
	
	List<AggregateResult> centerRateCount = null;
	List<AggregateResult> acctRateCount = null;
	Integer maxCtrRates = 0;
	Integer maxAcctRates = 0;
	Id centerId = null;
	Boolean isManualProcPricing = false;
	
	
	// Set<Id> procIds = trigger.newMap.keySet();
	// List<Procedure_c> procs = [SELECT Id,  FROM Procedure__c 
	//						   WHERE Id IN :procIds];
					   
	for (Procedure__c proc: trigger.new) {
		if (proc.Override_Procedure_Rate__c == false) {
			// get the Main Center ID for the current procedure
			try {
				centerId = [SELECT Main_Center__c FROM Center__c WHERE Id = :proc.Center__c][0].Main_Center__c;
			} catch (Exception e) {
				proc.addError('Unable to determine Main Center. Ensure that this procedure has a Center selected.');
				continue;
			}
			// determine if Manual Procedure Pricing checkbox is checked
			isManualProcPricing = [SELECT Manual_Procedure_Pricing__c FROM Main_Center__c WHERE Id = :centerId][0].Manual_Procedure_Pricing__c;
			if (isManualProcPricing == false) {
				// only process the costs if entering a new procedure or updating an existing one that has a blank amount and cost
				// or updating an existing one only if the Procedure Status is not 'OK to Pay' or 'Paid')
				if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					centerRateCount = 
						[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
						 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
						
					if (maxCtrRates == 0) {
						System.debug('proc.Center__c = ' + proc.Center__c);
						// no rates found in Center Procedure Rate object, so look at Account Procedure Rate object for rate
						acctRateCount = [SELECT COUNT(Id) maxRates FROM Account_Procedure_Rate__c 
							 			 WHERE CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId];
						maxAcctRates = acctRateCount[0].get('maxRates') == null ? 0 : (Integer)acctRateCount[0].get('maxRates');
						
						if (maxAcctRates == 0) { 
							proc.addError('No rates found for this procedure.');
						} else if (maxAcctRates == 1) {
							Account_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Account_Procedure_Rate__c 
														 	 WHERE  CPT_Code__c = :proc.CPT_Code__c AND Main_Center__c = :centerId];
							proc.Amount_To_Pay__c = rate.Amount_To_Pay__c;
							proc.Procedure_Cost__c = rate.Procedure_Cost__c;
						} else {
							proc.addError('More than one procedure rate for the main center was found.');
						}
					} else if (maxCtrRates == 1) {
						Center_Procedure_Rate__c rate = [SELECT Amount_To_Pay__c, Procedure_Cost__c FROM Center_Procedure_Rate__c 
														 WHERE  CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						proc.Amount_To_Pay__c = rate.Amount_To_Pay__c;
						proc.Procedure_Cost__c = rate.Procedure_Cost__c;
					} else {
						proc.addError('More than one procedure rate for the center was found.');
					}
				}
			}
		}
	} 
}



Thanks,
Keith.
Hello All,
I need to be able to update an Azure database from Salesforce.  Mainly for Cases and Lawyers, when cases or lawyers get updated I need to update the Azure DB as well.
I have seen the examples that talk about Azure to Salesforce, but I have not seen anything talking about Salesforce to Azure.
I have looked at both the Salesforce WCF and RestAPI https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/
But again these go from Azure to Salesforce.

Is it possible to go the other way?  What would be the best approch to this as I have seen many differnt approches to connecting.
We don't want any syncing of data, just to make a .NET call when Salesforce records get updates ect.. to update our Azure DB.
Thanks,
K.