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

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 31
    Replies
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.
I am calling Salesforce query api call, and I am wanting to pass in a case id, but it is not working.
I have tried to add single quotes around the ID but that did ot work either.
If I remove the where clause it works just fine.
Any help would be appritiated.
Thanks,
Keith.
 
String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Plaintiff_First_Name__c,Plaintiff_Last_Name__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Last_Name__c+FROM+Case+WHERE+Id=500g000000G1DB4';
system.debug(url);
Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);


 
Hello all,
I am making a rest api call from the developer console that just calls SF AIP /query?q passing in a simple SOQL statment.
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,Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+limit+3';

This works fine, but now I want to add the logged in users email address, everything I have tried is not working.
example String userEmail = UserInfo.getUserEmail();
And adding userEmail in my soql string ect..

How can I get the email to be passed in the query.
Thanks,
Keith.
I am needing to include a string of text in my soql query. Is this possible?
In sql server the following query works and returns the text, but how do I do this using SOQL?

SELECT [LastModifeidDate]
      ,[Plaintiff_Full_Name__c]
      ,[Pliantif_Last_Name__c],
   'hello world'
  FROM [ERP].[dbo].[Cases]
Thanks,
KS
Hello All,
How do I write a simple Salesforce class that will execute this soql "SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3"
And return a Json string so I can pass that to my C# rest service.
And for testing sake call the class from the Developer Console.

Thanks for any help, I am learning SF as I go.
Keith.
Hello All,
I am calling Salesforce API to retun me the version /services/data/
But the returned JSON I get has backslashes infront of the double quotes.
How do I remove the backshash \?  Also in my c# rest service I am using NewtonSoft_Json.Linq.
Here is my c# code to call Salesforce API.
I have a Return just before parsing so I can get the JSON being returned.
But when it does hit the parser it errors out.
 
HttpClient apiCallClient = new HttpClient();
               
                String restCallURL = ServiceURL + "/services/data/";

                HttpRequestMessage apirequest = new HttpRequestMessage(HttpMethod.Get, restCallURL);
                apirequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                apirequest.Headers.Add("authorization", "Bearer " + authToken);
                HttpResponseMessage apiCallResponse = await apiCallClient.SendAsync(apirequest);


                string requestresponse = await apiCallResponse.Content.ReadAsStringAsync();
                
                // Regex.Unescape(requestresponse);
                //requestresponse = requestresponse.Replace('\"', '"');
                //string x = requestresponse.Replace("\n", "").Replace("\r", "");

                // return x.ToString();
                 return requestresponse.ToString();
//This is where my code breaks on the parsing of the string because of \
 JToken sObjJObj = JObject.Parse(requestresponse);
                return "obj " + sObjJObj.ToString();

JSON String.
"[{\"label\":\"Winter '11\",\"url\":\"/services/data/v20.0\",\"version\":\"20.0\"},{\"label\":\"Spring '11\",\"url\":\"/services/data/v21.0\",\"version\":\"21.0\"},{\"label\":\"Summer '11\",\"url\":\"/services/data/v22.0\",\"version\":\"22.0\"},{\"label\":\"Winter '12\",\"url\":\"/services/data/v23.0\",\"version\":\"23.0\"},{\"label\":\"Spring '12\",\"url\":\"/services/data/v24.0\",\"version\":\"24.0\"},{\"label\":\"Summer '12\",\"url\":\"/services/data/v25.0\",\"version\":\"25.0\"},{\"label\":\"Winter '13\",\"url\":\"/services/data/v26.0\",\"version\":\"26.0\"},{\"label\":\"Spring '13\",\"url\":\"/services/data/v27.0\",\"version\":\"27.0\"},{\"label\":\"Summer '13\",\"url\":\"/services/data/v28.0\",\"version\":\"28.0\"},{\"label\":\"Winter '14\",\"url\":\"/services/data/v29.0\",\"version\":\"29.0\"},{\"label\":\"Spring '14\",\"url\":\"/services/data/v30.0\",\"version\":\"30.0\"},{\"label\":\"Summer '14\",\"url\":\"/services/data/v31.0\",\"version\":\"31.0\"},{\"label\":\"Winter '15\",\"url\":\"/services/data/v32.0\",\"version\":\"32.0\"},{\"label\":\"Spring '15\",\"url\":\"/services/data/v33.0\",\"version\":\"33.0\"},{\"label\":\"Summer '15\",\"url\":\"/services/data/v34.0\",\"version\":\"34.0\"},{\"label\":\"Winter '16\",\"url\":\"/services/data/v35.0\",\"version\":\"35.0\"},{\"label\":\"Spring '16\",\"url\":\"/services/data/v36.0\",\"version\":\"36.0\"},{\"label\":\"Summer '16\",\"url\":\"/services/data/v37.0\",\"version\":\"37.0\"},{\"label\":\"Winter '17\",\"url\":\"/services/data/v38.0\",\"version\":\"38.0\"},{\"label\":\"Spring '17\",\"url\":\"/services/data/v39.0\",\"version\":\"39.0\"},{\"label\":\"Summer '17\",\"url\":\"/services/data/v40.0\",\"version\":\"40.0\"},{\"label\":\"Winter '18\",\"url\":\"/services/data/v41.0\",\"version\":\"41.0\"}]"
Hello All,
I am making a call from my c# rest service to try and get Salesforce latest version number, but SF is not retuning a parsable Json stirng.
HttpClient apiCallClient = new HttpClient();
            //String restCallURL = ServiceURL + "/services/data/v40.0/sobjects";                
            String restCallURL = ServiceURL + "/services/data/";
            
            HttpRequestMessage apirequest = new HttpRequestMessage(HttpMethod.Get, restCallURL);
            apirequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            apirequest.Headers.Add("authorization", "Bearer " + authToken);
            HttpResponseMessage apiCallResponse = await apiCallClient.SendAsync(apirequest);

            String requestresponse = await apiCallResponse.Content.ReadAsStringAsync();

           // String jsonResult = requestresponse.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' });

            List<String> sObjLst = new List<String>();
            return requestresponse.ToString();
            
            if (apiCallResponse.IsSuccessStatusCode)
            {

                JObject sObjJObj = JObject.Parse(requestresponse);
                return sObjJObj.ToString();

            }
In the above code requestresponse equals, below but newtonsoft_Json is not able to parse it, and if I try and parse it with online parsers they also return errors.

[{\"label\":\"Winter '11\",\"url\":\"/services/data/v20.0\",\"version\":\"20.0\"},{\"label\":\"Spring '11\",\"url\":\"/services/data/v21.0\",\"version\":\"21.0\"},{\"label\":\"Summer '11\",\"url\":\"/services/data/v22.0\",\"version\":\"22.0\"},{\"label\":\"Winter '12\",\"url\":\"/services/data/v23.0\",\"version\":\"23.0\"},{\"label\":\"Spring '12\",\"url\":\"/services/data/v24.0\",\"version\":\"24.0\"},{\"label\":\"Summer '12\",\"url\":\"/services/data/v25.0\",\"version\":\"25.0\"},{\"label\":\"Winter '13\",\"url\":\"/services/data/v26.0\",\"version\":\"26.0\"},{\"label\":\"Spring '13\",\"url\":\"/services/data/v27.0\",\"version\":\"27.0\"},{\"label\":\"Summer '13\",\"url\":\"/services/data/v28.0\",\"version\":\"28.0\"},{\"label\":\"Winter '14\",\"url\":\"/services/data/v29.0\",\"version\":\"29.0\"},{\"label\":\"Spring '14\",\"url\":\"/services/data/v30.0\",\"version\":\"30.0\"},{\"label\":\"Summer '14\",\"url\":\"/services/data/v31.0\",\"version\":\"31.0\"},{\"label\":\"Winter '15\",\"url\":\"/services/data/v32.0\",\"version\":\"32.0\"},{\"label\":\"Spring '15\",\"url\":\"/services/data/v33.0\",\"version\":\"33.0\"},{\"label\":\"Summer '15\",\"url\":\"/services/data/v34.0\",\"version\":\"34.0\"},{\"label\":\"Winter '16\",\"url\":\"/services/data/v35.0\",\"version\":\"35.0\"},{\"label\":\"Spring '16\",\"url\":\"/services/data/v36.0\",\"version\":\"36.0\"},{\"label\":\"Summer '16\",\"url\":\"/services/data/v37.0\",\"version\":\"37.0\"},{\"label\":\"Winter '17\",\"url\":\"/services/data/v38.0\",\"version\":\"38.0\"},{\"label\":\"Spring '17\",\"url\":\"/services/data/v39.0\",\"version\":\"39.0\"},{\"label\":\"Summer '17\",\"url\":\"/services/data/v40.0\",\"version\":\"40.0\"},{\"label\":\"Winter '18\",\"url\":\"/services/data/v41.0\",\"version\":\"41.0\"}]

Thanks for any help or advice.
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 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.
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.
I am calling Salesforce query api call, and I am wanting to pass in a case id, but it is not working.
I have tried to add single quotes around the ID but that did ot work either.
If I remove the where clause it works just fine.
Any help would be appritiated.
Thanks,
Keith.
 
String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Plaintiff_First_Name__c,Plaintiff_Last_Name__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Last_Name__c+FROM+Case+WHERE+Id=500g000000G1DB4';
system.debug(url);
Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);


 
Hello all,
I am making a rest api call from the developer console that just calls SF AIP /query?q passing in a simple SOQL statment.
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,Attorney_Last_Name__c,Id,Plaintiff_First_Name__c,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c+FROM+Case+limit+3';

This works fine, but now I want to add the logged in users email address, everything I have tried is not working.
example String userEmail = UserInfo.getUserEmail();
And adding userEmail in my soql string ect..

How can I get the email to be passed in the query.
Thanks,
Keith.
Hello All,
How do I write a simple Salesforce class that will execute this soql "SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3"
And return a Json string so I can pass that to my C# rest service.
And for testing sake call the class from the Developer Console.

Thanks for any help, I am learning SF as I go.
Keith.
Hello All,
I am making a call from my c# rest service to try and get Salesforce latest version number, but SF is not retuning a parsable Json stirng.
HttpClient apiCallClient = new HttpClient();
            //String restCallURL = ServiceURL + "/services/data/v40.0/sobjects";                
            String restCallURL = ServiceURL + "/services/data/";
            
            HttpRequestMessage apirequest = new HttpRequestMessage(HttpMethod.Get, restCallURL);
            apirequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            apirequest.Headers.Add("authorization", "Bearer " + authToken);
            HttpResponseMessage apiCallResponse = await apiCallClient.SendAsync(apirequest);

            String requestresponse = await apiCallResponse.Content.ReadAsStringAsync();

           // String jsonResult = requestresponse.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' });

            List<String> sObjLst = new List<String>();
            return requestresponse.ToString();
            
            if (apiCallResponse.IsSuccessStatusCode)
            {

                JObject sObjJObj = JObject.Parse(requestresponse);
                return sObjJObj.ToString();

            }
In the above code requestresponse equals, below but newtonsoft_Json is not able to parse it, and if I try and parse it with online parsers they also return errors.

[{\"label\":\"Winter '11\",\"url\":\"/services/data/v20.0\",\"version\":\"20.0\"},{\"label\":\"Spring '11\",\"url\":\"/services/data/v21.0\",\"version\":\"21.0\"},{\"label\":\"Summer '11\",\"url\":\"/services/data/v22.0\",\"version\":\"22.0\"},{\"label\":\"Winter '12\",\"url\":\"/services/data/v23.0\",\"version\":\"23.0\"},{\"label\":\"Spring '12\",\"url\":\"/services/data/v24.0\",\"version\":\"24.0\"},{\"label\":\"Summer '12\",\"url\":\"/services/data/v25.0\",\"version\":\"25.0\"},{\"label\":\"Winter '13\",\"url\":\"/services/data/v26.0\",\"version\":\"26.0\"},{\"label\":\"Spring '13\",\"url\":\"/services/data/v27.0\",\"version\":\"27.0\"},{\"label\":\"Summer '13\",\"url\":\"/services/data/v28.0\",\"version\":\"28.0\"},{\"label\":\"Winter '14\",\"url\":\"/services/data/v29.0\",\"version\":\"29.0\"},{\"label\":\"Spring '14\",\"url\":\"/services/data/v30.0\",\"version\":\"30.0\"},{\"label\":\"Summer '14\",\"url\":\"/services/data/v31.0\",\"version\":\"31.0\"},{\"label\":\"Winter '15\",\"url\":\"/services/data/v32.0\",\"version\":\"32.0\"},{\"label\":\"Spring '15\",\"url\":\"/services/data/v33.0\",\"version\":\"33.0\"},{\"label\":\"Summer '15\",\"url\":\"/services/data/v34.0\",\"version\":\"34.0\"},{\"label\":\"Winter '16\",\"url\":\"/services/data/v35.0\",\"version\":\"35.0\"},{\"label\":\"Spring '16\",\"url\":\"/services/data/v36.0\",\"version\":\"36.0\"},{\"label\":\"Summer '16\",\"url\":\"/services/data/v37.0\",\"version\":\"37.0\"},{\"label\":\"Winter '17\",\"url\":\"/services/data/v38.0\",\"version\":\"38.0\"},{\"label\":\"Spring '17\",\"url\":\"/services/data/v39.0\",\"version\":\"39.0\"},{\"label\":\"Summer '17\",\"url\":\"/services/data/v40.0\",\"version\":\"40.0\"},{\"label\":\"Winter '18\",\"url\":\"/services/data/v41.0\",\"version\":\"41.0\"}]

Thanks for any help or advice.
Keith.
Hello All,
I have the follwoing Rest call in Salesforce development console and it seems to be working, but how to I read the request in my C# method the URI is pointing too.
String Soql = 'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';
List<sObject> L = Database.query(Soql);
Bolden,Plaintiff_Last_Name__c=Bolden,Id=500g000000G3NmpAAF})';

String jsonResponse = Json.serialize(L);

String url = 'http://localhost:1025/ErpApiService/api/PriceForCustomerB/';

Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Content-Type', 'application/json');

req.setEndpoint(url);
system.debug('setendpoint');
//req.setMethod('GET');
req.setMethod('POST');
req.setBody(jsonResponse);
HttpResponse res = h.send(req);
Thanks for any help or advice,
Keith.
 
Needing help to get Case information to my C# rest service.
Below is my code, but I am getting "Bad Request" error.
I am not sure what I need to do to get my query results to my service for reading.
Thanks,
KS
String Soql = 'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';
List<sObject> L = Database.query(Soql);
String url = 'http://server/ErpApiService/api/PriceForCustomerB/' + L;

System.Debug(url);

Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Content-Type', 'application/json');

req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);

 system.debug('res' + res);
system.debug('Price: ' + res.getBody());

 
Hello All
I am new to Salesforce and Restful services.
But I currently have a c# rest service running and I am able to call it from SF, but currently I am just passing in a hard coded string value.
Here is my code that I can run from the Development Console
 
String url = 'http://server/ErpApiService/api/PriceForCustomerA/10/15';

Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);
 system.debug('res' + res);
system.debug('Price: ' + res.getBody());

And this works and calls my rest service passing in a string value, but now I want to pass back some actual data from salesforce example
'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';
I know I will have to change my parameter in my rest service to accept whatever SF will be passing to me.

But here I am not sure what or how to do this? Do I need to create a dictionary object, and pass that?
What do I need to do in SF to pass query results and then read them in my rest service.
Thanks for any help or advice,
Keith.
 
Hello All,
One I am new to SF and Apex and their triggers, but I wrote this trigger and at one time it worked in Dev. Now it is not updating the list, with all my system.debug statements it gets all the way down to the update lstCase; statment but then errors out.
Can someone help me out on what might be happening now.
Thanks,
Keith.
 
trigger MostRecentCenter on Procedure__c (after insert, after update) {
   try{           
            
           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 = 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');
    }
    
}

 
Hello all,
I am new with Apex and Salesforce so bare with me.
Up until now all the triggers I have written work just fine in Dev/QA and production.
But now I have this one trigger that needs a test class, but I am not sure where to being.
If someone can help me develop a test class that for the trigger below, then I should be able to understand how to test my triggers in the future. How to get the data needed to test the triggers ect...
Thanks,
Keith.
trigger MostRecentCenter on Procedure__c (after insert, after update) {
   try{           
            
           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;
            caseMap.get(pd.Case__c).Most_Recent_Center__c = procMap.get(pd.id).Center__c;
                        lstCase.add(caseMap.get(pd.Case__c));                      
                                                               
                    }       
                }
                //system.debug(lstCase.size());
        if(lstCase.size()>0)
          update lstCase;
                
          //  }    //End of trigger.isBefore
        
    }catch(Exception e){
       //Package suspended, uninstalled or expired, exit gracefully.
       System.debug('MostRecentCenter');
    }
    
}

 
Is it possible to have the user get an email, everytime they log into Salesforce?  If so How?
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.