• Steve Thurston 3
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
I am trying to integrate with an external third party system that sends an XML response.  I need to map from their XML tags to the Salesforce fields I want to write the values to.  These fields change, so I don't want to hard code the mapping in the APEX code, as that would require a deployment every time there is a change, which means the admin can't do it.

I figure I can use Custom Settings for this.  Namely, I have a Custom Setting with the fields "Salesforce Field" and "Service Field".

My problem is that, while I can read the "Salesforce Field" into a variable in Apex - it's a variable.  How do I tell Apex to write to the actual field?

So it's easy enough to say something like:
   String salesforceWriteField = Custom_Setting__c.Salesforce_Field__c

But all I've achieved is to put the name of the field I want to write to in a variable.  Just as a simple example, if I want to write to the Name field on an Account, it could be:

MyAccount.Name

But I need to use the Custom Setting to tell Apex to write to the "Name" field.  And I can't think of how to do that.

I would like to avoid SOQL, as that is one of the benefits of Custom Settings, and deploying is already a challenge because of the number of SOQL statements that occur across classes during testing.
I have a third party developer that is creating Lead records in Salesforce from a mobile app.  This has been working for months, so that I stopped testing it months ago.  Now, as part of end-to-end testing, I have come back to this functionality - and it's not working.  I have no idea why.  As far as I know, niether I nor the third party has changed code that should affect this.  Further, my logs don't show any errors,altough their own logs do show an error.

Basically, looking at my logs, what happens is that the mobile app submits the Lead to Salesforce, Salesforce gets the Lead request, and then stops.  Complete log record:

Request Type;  API
Status:  Success

The complete log record:

42.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,FINEST;DB,FINEST;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,FINER 11:28:06.0 (647343)|USER_INFO|[EXTERNAL]|<ACTUAL LOG HAS SANDBOX USER INFO HERE>|Pacific Standard Time|GMT-07:00 11:28:06.0 (754319)|EXECUTION_STARTED 11:28:06.0 (760660)|CODE_UNIT_STARTED|[EXTERNAL]|Flow:Lead 11:28:06.0 (1172495)|CODE_UNIT_FINISHED|Flow:Lead 11:28:06.0 (1186927)|EXECUTION_FINISHED

That's it.  That's the complete log.  The third party developer says that they had the Lead creation fail once last night, and then the rest were successful.  Mine aren't succeeding at all.  The Salesforce logs for their successful attempts have exactly the same messages as above, but then continue on showing it firing my triggers and additional code I've got set up.  When I submit, it doesn't seem to fire my code at all.

No Lead is created when it fails.

For their failure, in their own logs, they got the error:

"Error: Invalid record ID. Specify valid record ID value"

Since this isn't hitting my own code at all, I don't have any system.debug information.

Any idea what might be going on?
 
I have a mobile app that needs to get and set datetime information in Salesforce.  The user enters a time in the app, the user's time zone is set from a picklist in the app (which is a picklist in Salesforce), and then the app needs to convert the time into UTC and push it into Salesforce, or pull a datetime from Salesforce that is UTC and convert it to the timezone set in the mobile app.

There are lots of posts about how to handle time zones if you are in Salesforce using Apex, but I haven't found anything where you are trying to deal with multiple time zones when integrating with an outside custom app.

How do you handle getting and setting times when communicating with an outside app?

Daylight Savings time zones are perhaps the biggest problem, because the offset is determined by what the date is in the year.  So you can't just say, "PST is -8 hour offset from GMT", because for part of the year it's -7.  And when that time starts/ends changes from year to year.

Communication between the app and Salesforce is being handled via JSON.
A third party integrator is creating a Lead to which multiple services can be attachec.  "Covered Service" is a custom object that has a Lookup(Lead) field to the associated Lead.

I am seeing something I have never seen before and didn't even know was possible.  When I look at one of these Covered Services, the "Provider Lead" field has the same Lead in the field TWICE!  A single Lookup field with two values!  Screenshot snippet attached.

User-added image

I think this might be causing some problems I'm having with some Apex code I'm running.  But I've turned off that code to try and make sure I'm not doing something, and it's still happening.  I'm at a lost even how to track this one down with out developers, since I didn't know this was possible.

Any help appreciated!
My developers are getting an error when trying to update a custom object record using their external code communicating with our Salesforce instance.  The error doesn't mean anything to me at all, so I don't know how to guide them.  "yapacopia" is the company name.  Does anyone know what this error means, and how I can guide them?

{ NOT_FOUND: The requested resource does not exist
0|app  | at HttpApi.getError (/opt/bitnami/apps/node/yapacopia/node_modules/jsforce/lib/http-api.js:250:13)
0|app  | at /opt/bitnami/apps/node/yapacopia/node_modules/jsforce/lib/http-api.js:95:22
0|app  | at tryCallOne (/opt/bitnami/apps/node/yapacopia/node_modules/promise/lib/core.js:37:12)
0|app  | at /opt/bitnami/apps/node/yapacopia/node_modules/promise/lib/core.js:123:15
0|app  | at flush (/opt/bitnami/apps/node/yapacopia/node_modules/asap/raw.js:50:29)
0|app  | at _combinedTickCallback (internal/process/next_tick.js:132:7)
0|app  | at process._tickCallback (internal/process/next_tick.js:181:9) name: 'NOT_FOUND', errorCode: 'NOT_FOUND' } undefined
When creating a new Lead via an API call, I need to set the RecordType.  To do that, it seems as if I need the RecordTypeId.  But for testing, that ID is going to be different in Sandbox vs. Production.  So I don't want to hardcode the RecordTypeId.

When creating a new Lead via API, is there a way to specify the Record Type using its name instead of its ID?  Or at least have the API look up the RecordTypeId based on its name?
I am working to build an ANT Migration package that can be rolled back, preferably with a single ANT command.  I'm not working with any data yet.  Simply trying to deploy the metadata and then immediately undeploy the changes.  Using destructiveChanges.xml to list the desired deletions.  Right now that file is just a direct copy and rename of the deployment file, package.xml.  I'm encountering several issues.

So far:

1)  "Error: You can't delete an active Lightning page"  Ok, I deactivated it, but manually deactivating a bunch of Lightning pages is hardly ideal for automation.

QUESTION:  Is there a way around that will enable me to delete these pages without having to manually deactivating them before using ANT?

2)  "Error: Cannot delete record type through API"

QUESTION:  How do I get around this?

3)  "Error: This global picklist is used by 1 or more custom fields. Remove the usage and try again."

QUESTION:  I thought deployments weren't supposed to get hung up on dependencies, but resolve them as part of the process?  In other words, yes, the global picklist is used by custom fields - the fields I just deployed using ANT, and the ones that I am trying to delete using ANT!
When creating a new Lead via an API call, I need to set the RecordType.  To do that, it seems as if I need the RecordTypeId.  But for testing, that ID is going to be different in Sandbox vs. Production.  So I don't want to hardcode the RecordTypeId.

When creating a new Lead via API, is there a way to specify the Record Type using its name instead of its ID?  Or at least have the API look up the RecordTypeId based on its name?