-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Anonymous Apex? #132
Comments
Hi @perbrondum - yes, you could execute anonymous Apex by creating your own struct that conforms to Swiftly Salesforce's Service protocol (example here) and calls the Salesforce Tooling API as described here. You could also create a custom Apex web service that both queries and deletes records, and then call that web service via Swiftly Salesforce's Another alternative: create a custom Service that calls the Salesforce Composite API to delete multiple record IDs as shown here. |
Cool. Thanks. We will try that.
We tried the apex REST call but got stuck on getting access to the sessionId. Is there a trick to get the sessionId from connectedApp inside swift?
Thanks again for supporting swiftlysalesforce.
Per
… On Jul 28, 2021, at 6:36 PM, Michael Epstein ***@***.***> wrote:
Hi @perbrondum - yes, you could execute anonymous Apex by creating your own struct that conforms to Swiftly Salesforce's Service protocol (example here) and calls the Salesforce Tooling API as described here.
You could also create a custom Apex web service that both queries and deletes records, and then call that web service via Swiftly Salesforce's apex method.
Another alternative: create a custom Service that calls the Salesforce Composite API to delete multiple record IDs as shown here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@perbrondum if you use Swiftly Salesforce's If you do need to retrieve the access token, you could get it via |
Awesome. Thank you.
Per
… On Jul 29, 2021, at 9:37 PM, Michael Epstein ***@***.***> wrote:
@perbrondum if you use Swiftly Salesforce's apex method then you won't need the session ID. You just need to provide the method arguments (or accept the defaults if applicable).
If you do need to retrieve the access token, you could get it via ConnectedApp's getCredential method.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
This is very cool, except I can’t seem to get the return type right (which
I assume is json with status of the job).
*private* *func* bulkDeleteContent(type: contentSegment) {
DB.salesforce.identity().sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* .finished:
*break*
*case* *let* .failure(error) :
print("Failed to login. Error: \(error)")
}
}) { identity *in*
// Call relevant APEX
*let* method : HTTPMethod = .delete
*let* path = "/\(instanceName).salesforce.com/services/apexrest/
\(type)"
DB.salesforce.apex(method: method,
path: path,
parameters: [:],
body: *nil*,
headers: *nil*,
config:
Salesforce.RequestConfig()).sink(receiveCompletion:
{ (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print("Failed to execute Apex. Error:
\(error)")
*case* .finished:
print("Success executing Apex \(type)")
*break*
}
}, receiveValue: { result *in*
//
}).store(in: &*self*.subscriptions)
}.store(in: &*self*.subscriptions)
}
Error: Unable to infer type of a closure parameter 'result' in the current
context
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
…On Jul 29, 2021 at 9:52:51 PM, Per Jakobsen ***@***.***> wrote:
Awesome. Thank you.
Per
On Jul 29, 2021, at 9:37 PM, Michael Epstein ***@***.***>
wrote:
@perbrondum <https://github.com/perbrondum> if you use Swiftly
Salesforce's apex
<https://github.com/mike4aday/SwiftlySalesforce/blob/60c9506808b3c4e62f5f1cbfbd9c6e8061458315/Sources/SwiftlySalesforce/ConnectedApp%2BApex.swift#L29>
method then you won't need the session ID. You just need to provide the
method arguments (or accept the defaults if applicable).
If you do need to retrieve the access token, you could get it via
ConnectedApp's getCredential method
<https://github.com/mike4aday/SwiftlySalesforce/blob/60c9506808b3c4e62f5f1cbfbd9c6e8061458315/Sources/SwiftlySalesforce/ConnectedApp.swift#L74>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#132 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALCYWDGZR2NZJXMJ6Z7M7LLT2GUVVANCNFSM5A5XE5VA>
.
|
Hi @perbrondum It's difficult for me to follow the unformatted code, but let me offer this:
|
@perbrondum here's an example of calling an Apex method exposed as a REST endpoint. The |
Trying to truncate custom objects via the API i've hit a dead stop. One workaround would be to execute the following Apex:
//
List<WIWO_Content__c> contentDelete = New List<WIWO_Content__c>();
contentDelete = [SELECT CreatedById FROM WIWO_Content__c LIMIT 10000];
delete contentDelete;
//
Is there some way to call Anonymous Apex inside SwiftlySalesforce?
The text was updated successfully, but these errors were encountered: