I have a custom button in Salesforce and a python script which takes the data from Accounts table, perform some logic and save it in an object (a different table).
I want to execute python script by clicking the custom button. Hence, is there any way to execute the python script through Apex class?
You can't run the Python on Salesforce so you'll need to run it somewhere else like Heroku. Then when the button is clicked you'll need to send the data to the Python app via something like a Webhook or Apex callout.
Related
I am new to salesforce and I am trying working on an integration, where I need to send object schema to a third party system. I was able to create a simple apex class to create a JSON message and send it to an end point.
I am trying to figure out how to automate this, meaning.. I want to trigger this apex class when an new field is created or an existing field is modified in a specific custom object.
Created an apex class to generate a JSON with the list of custom fields in the object and their properties. I want to be able to trigger this automatically when object is updated
There's a "you're doing it wrong" element to it. It's metadata, not data, not so easy to trigger from inside Apex. Salesforce has mechanisms for easy pulling of this info, not pushing. External system can call "describes" with If-Modified-Since, querying EntityDefinition, FieldDefinition with Tooling API...
Even if you pull it off - technically it'll be useless to external system. When you created new field but didn't modify Profiles/Permission Sets yet - attempts to query it will fail. Same error is thrown for genuine syntax errors in SOQL and for "yes, we do have such field but you're not authorised to see it".
If you really want to continue down this path you can look into scheduling Apex (say run every 5 minutes, will that be good enough? Class to check EntityDefinition or Setup Audit Trail and send the message if needed)
We have logic apps running in azure.
We can query some details of past runs in azure log analytics.
Log analytics does not seem to contain any of the output from each task in the logic app, even though i can see this in the logic app history.
Is there a way to query the data/payloads/output from each task in the logic app?
Yes, you can get logs of Logic apps, I have followed below process:
Firstly, open your Log analytics workspace
In general tab open workspace summary as below:
then click on add as below:
Then click on Logic apps managemnet(preview):
The click on create:
Then give details and click on create:
Then open your created as below:
Then, I have created a workflow in logic app and then I opened Diagnostic settings as below:
Then give important details as below:
open your Log analytics workspace
In general tab open workspace summary as below:
Then you will get output as below:
When you click on chart you will get information like below:
If you click on row of LogicApp(table in above display)
Alternatively in work summary in log analytics, click on logs and then You can the below kql query to get logs and you can export it using export option as below:
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.LOGIC"
| where OperationName has "workflowRunCompleted"
You can also send a email of payload (example SO-thread) to check your runs or you can create an alert on each run in logicapp.
How can you obtain the full URL of a HTTP triggered Logic App in the Azure Portal, if you can't use the designer?
Usually if I create a logic app with the HTTP trigger, after the first time I save it, the "Designer" has the full URL, including the sig, and even an option to "Copy Url", e.g.
https://prod.northeurope.logic.azure.com:443/workflows/.../paths/invoke?...&sig=xxxxxxx
But if I create a logic app in the "Code view" with multiple triggers, e.g. one for GET, one for POST, I can't switch to the "Designer".
So how can I get the full URL?
... without using e.g. PowerShell and the Az cmdlets, e.g.
Get-AzLogicAppTriggerCallbackUrl
-ResourceGroupName $(LogicAppResourceGroupName)
-Name $(LogicAppName-ProcessData)
-TriggerName "manual"
Actually Logic app http trigger endpoint URL is a sas URL with below format:
https://<request-endpoint-URI>sp=<permissions>sv=<SAS-version>sig=<signature>
And you don't have dev tool, the efficient ways are the REST API:listcallbackurl and the Az command:Get-AzLogicAppTriggerCallbackUrl.
The rest api description provides a simple way to test the API with Try it button, just log in without additional auth token generation.
Also Azure Portal provides the Azure Cloud Shell to use the PowerShell and Bash command to manage Azure resources.
If you can use the Run Trigger button and select the Run with payload buttons in the code view, you can get the full url from the pane that pops up, with a convenient button to copy the full url.
I have added the alert rule and action group manually in the Azure portal to send mail whenever it fails.
Is it possible to create these things using the Azure resource manager template?
Yes, this tutorial will help you create the alert using ARM template. You can refer to the "simplestaticmetricalert.json" and "simplestaticmetricalert.parameters.json" in this tutorial and replace the parameters in json with your parameters. Then use PowerShell or Azure CLI to deploy the template.
By the way, if you are confused about some parameters in "simplestaticmetricalert.parameters.json", you can use this command below
az monitor metrics alert show [--ids]
[--name]
[--resource-group]
[--subscription]
to show the properties of the alert you have created before for your reference when you edit the new template.
I have a salesforce I export to CSV using a URL like this https://tapp0.salesforce.com/00OT00000014APi?export=1&enc=UTF-8&xf=csv following this blog post.
This works fine and is very fast when I run for a fully licenced user.
However when I try to call the same report export as a Gold Patner portal user I get an error "Insufficient Privileges"
I have marked the report as deployed.
Given all users access to the Report Folder
The user does have the correct sharing and profile rules setup to view the data in the report.
Going to just the report URL by itself works https://tapp0.salesforce.com/00OT00000014APi
It only fails when I try to export to CSV.
I DO reliase I am using an unsuported internal API call. But was wondering is there anyway portal users can export reports to CSV?
Not sure about through the UI, but this can be done through a SOQL query and portal users do have limited access to the API. Most, but not all, reports can be converted to SOQL queries to produce the same output.
For running your query, the easiest is probably to build a Visualforce page that is backed by an Apex controller that runs the query and outputs a CSV. Take a look at the contentType attribute on the apex:page tag. You can set things like application/vnd.ms-excel#contacts.xls to automatically export a data table to Excel. I didn't try, but it probably works with CSV too -- worst case is that you open in Excel first and save as CSV.
Also, if you don't mind portal users having to leave Salesforce to get their CSV, you might want to try Workbench, which is an app I built that allows for portal user login and helps you build the SOQL query for CSV export both through the SOAP and Bulk APIs.
Ok I found the problem
You need to go to Salesforce > Setup > Manage Users > Profiles
Then Click to Edit the RS_PortalUser profile
Click the checkbox next to “Run Reports” and “Export Reports”
Click save