Jump to content

Search in Salesforce (Alfred worklfow)


Recommended Posts

Description

 

Alfred workflow to search in Salesforce.

 

salesforce-on-mac.gif.1f8a90f1080af17551288f87bedb703d.gif


Keywords

 

  • `sf [blabla]` to search for any contact, account, opportunity, lead
  • `sf > login` to connect
  • `sf > logout` to log out
  • `sf > switch` to switch the opening between Salesforce Classic and Salesforce Lightning
  • `sf > debug` to write some debugs logs


Requirements

 

  • Alfred version 3 or 4 or 5 (please see the release notes on the Github page to know which version of the workflow to use)
  • A Salesforce account with access to the REST API
  • From macOS Monterey 12.3, you'll need to install Python 3 (it is easy to install with Xcode command line tools provided by Apple, see instructions here)

 

Resources

 

 

 

Edited by jereze
Link to comment
  • 2 weeks later...

I love this!! Thank you for developing it.

 

There seems to be a bug. Occasionally, when I type in a command it says "Type at least two characters to search in Salesforce", no matter how many characters are in there. Then when I hit enter a notification pops up saying "New access token" and it starts working normally again. It's not a huge issue because it works fine after that, but I find it occasionally does this. Any idea why?

Thanks again for making this

Link to comment

Hi able,

 

Thank you very much for your feedback.

 

Hum, I'm not able to reproduce the bug you mention. Are you typing very fast when you get wrongly the "Type at least two characters to search in Salesforce" message?

 

About the notification: the token (ie. authorization) given by the Salesforce REST API expires after few hours. So the workflow needs to refresh the token every few hours. I should remove the notification.

 

I will wait for more feedbacks before releasing a new version with bugfixes.

Link to comment

Looks useful. I have a few observations from reading the code:

 

Is requests really necessary for this workflow? It looks like Alfred-Workflow's http library would be sufficient. The workflow's almost 20MB, and it looks like it could be under 500KB.

 

You might also want to consider skipping logging.basicConfig(). The Workflow object initialises a "smarter" logger. It logs to a file in the workflow's cache directory (so Dropbox won't constantly be syncing the logfile in the workflow directory) and uses a RotatingFileHandler to keep the size of the logfile sane. If you use Workflow.logger, you can then also enter workflow:openlog as a query to open the log file directly.

 

Also, you don't need to test the length of wf.args. Because you call the script with "$query" (in quotation marks) there will always be an argument, even if it's just an empty string.

Edited by deanishe
Link to comment
On 10/31/2017 at 3:41 PM, deanishe said:

Looks useful. I have a few observations from reading the code:

 

Is requests really necessary for this workflow? It looks like Alfred-Workflow's http library would be sufficient. The workflow's almost 20MB, and it looks like it could be under 500KB.

 

You might also want to consider skipping logging.basicConfig(). The Workflow object initialises a "smarter" logger. It logs to a file in the workflow's cache directory (so Dropbox won't constantly be syncing the logfile in the workflow directory) and uses a RotatingFileHandler to keep the size of the logfile sane. If you use Workflow.logger, you can then also enter workflow:openlog as a query to open the log file directly.

 

Also, you don't need to test the length of wf.args. Because you call the script with "$query" (in quotation marks) there will always be an argument, even if it's just an empty string.

 

Thank you deanishe. BTW, your library alfred-workflow is great, thank you for the great work.

 

In a first version, I was using Alfred-Workflow's http library but I had several Python SSL Errors. Using requests solved the issues. I thought including requests library would make the workflow more reliable across the different MacOS versions.

 

About the logging, that's a good suggestion you make. How can I use the logger of Workflow also in server.py that starts in a new process?

 

About the test on the length of wf.args, indeed, you are right. I will remove it.

 

Link to comment
2 hours ago, jereze said:

I had several Python SSL Errors

 

Oh right. Shame. Python's SSL support is pretty crappy.

 

2 hours ago, jereze said:

How can I use the logger of Workflow also in server.py that starts in a new process?

 

Just use it. I mean, you have a Workflow instance in there. It's the same logging library under the hood, so it will work just as well. The only thing you have to be really careful with when running parallel processes is Workflow.settings.

 

Link to comment
  • 4 months later...

Hey there!

 

Thank you for building this - really cool workflow and it would be extremely useful for productivity! Unfortunately, I am encountering an error message when I try to open the search results because our org isn't using Lightning Experience, but rather Salesforce Classic. Any advice?

Screen Shot 2018-03-28 at 5.07.39 PM.png

Link to comment
  • 2 weeks later...
On 4/7/2018 at 4:01 AM, jereze said:

Hi @wefikus!

 

Thanks for your message.

Can you confirm that you can search with the plugin but then you get an error when the page is opened in your browser? I will have a look at it very soon.

Hi @jereze thanks for getting back to me!

Yes, the search itself works very well - the error message appears when I try to open the record in the browser.

Thanks a million for looking into this!

Link to comment

Hi all,

 

I just published a new version (0.0.2). You should update manually (no auto update yet).

 

@wefikus : There is now an option to open links in Salesforce Classic. This should fix your issue.

 

@AcidAlfred : Indeed, some logs would be helpful. Also, do you know if your Salesforce organization has any IP restriction?

 

@deanishe : Thanks for your help :)

Edited by jereze
typo
Link to comment
16 minutes ago, jereze said:

Hi all,

 

I just published a new version (0.0.2). You should update manually (no auto update yet).

 

@wefikus : There is now an option to open link in Salesforce Classic. This should fix your issue.

 

@AcidAlfred : Indeed, some logs would be helpful. Also, do you know if your Salesforce organization has any IP restriction?

 

@deanishe : Thanks for your help :)

You're seriously awesome @jereze ! Thank you for such a quick turn around! Everything works flawlessly now!

Edited by wefikus
Link to comment

Thanks for the quick responses.

 

@deanishe Thank you for the Link

 

@wefikus It seems like there are no restricted IPs.

 

 

Below is the debugger output. I get the same error any time I start a "sf xxx" search. Logging in works fine.

 

Quote

[2018-04-15 17:29:32][STDERR: input.scriptfilter] 17:29:32 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:29:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:29:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:29:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:29:32 workflow.py:1628 DEBUG    Reading settings from `/Users/xxx/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
17:29:32 workflow.py:2423 DEBUG    Set last run version : 0.0.2
17:29:32 workflow.py:2267 DEBUG    Workflow finished in 0.135 seconds.
[2018-04-15 17:29:33][STDERR: input.scriptfilter] 17:29:32 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:29:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:29:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:29:33 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:29:33 workflow.py:1628 DEBUG    Reading settings from `/Users/xxx/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
17:29:33 workflow.py:2423 DEBUG    Set last run version : 0.0.2
17:29:33 workflow.py:2267 DEBUG    Workflow finished in 0.121 seconds.
[2018-04-15 17:29:38][ERROR: input.scriptfilter] Code 1: 17:29:33 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:29:33 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:29:33 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:29:33 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:29:38 salesforce_api.py:50 INFO     API get call: https://eu10.salesforce.com/services/data/v40.0/search/?q=FIND+{lead}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+
17:29:38 salesforce_api.py:57 DEBUG    [{"message":"\nFIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email)\n                                    ^\nERROR at Row:1:Column:56\nNo such column 'Type' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
17:29:38 workflow.py:2243 ERROR    API error when calling https://eu10.salesforce.com/services/data/v40.0/search/?q=FIND+{lead}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+ (400): [{"message":"\nFIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email)\n                                    ^\nERROR at Row:1:Column:56\nNo such column 'Type' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
Traceback (most recent call last):
  File "/Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5E6052FE-B26B-4BBA-A171-21BC8E59264E/workflow/workflow.py", line 2236, in run
    func(self)
  File "salesforce_search.py", line 136, in main
    'q': "FIND {%s} IN ALL FIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email), Opportunity (Id, Name, StageName, CloseDate), Lead (Id, Name) WITH METADATA='LABELS' " % query.replace("\\", "\\\\").replace("'", "\\'")
  File "/Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5E6052FE-B26B-4BBA-A171-21BC8E59264E/salesforce_api.py", line 58, in api_call
    raise ValueError('API error when calling %s (%i): %s' % (r.url, r.status_code, r.text))
ValueError: API error when calling https://eu10.salesforce.com/services/data/v40.0/search/?q=FIND+{lead}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+ (400): [{"message":"\nFIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email)\n                                    ^\nERROR at Row:1:Column:56\nNo such column 'Type' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
17:29:38 workflow.py:2267 DEBUG    Workflow finished in 4.694 seconds.

 

 

Link to comment
5 minutes ago, AcidAlfred said:

Thanks for the quick responses.

 

@deanishe Thank you for the Link

 

@wefikus It seems like there are no restricted IPs.

 

 

Below is the debugger output. I get the same error any time I start a "sf xxx" search. Logging in works fine.

 

 

 

 

Here is the error: "No such column 'Type' on entity 'Account'"

The plugin tries to get the Type on Accounts (a standard field), but Salesforce API returns an error. Do you know if the field 'Type' is available and retrievable?

Link to comment
  • 2 weeks later...

@jereze  Thanks for your help and excuse the late feedback. Indeed the "type" field in our org was hidden. After making it visible the search is now working. 

 

Do you think it would be possible to extend the workflow to be able to change e.g. the status of a lead?

 

Thanks a lot, this is great,

Benedikt

 

 

Link to comment
  • 3 weeks later...

@AcidAlfred Sorry for answering late. Great that the plugin now works.

Updating fields with the plugin is possible. But which objects (leads, contacts, opportunities...) should be editable, and which of their field (only the status?)? If the plugin allows editing, it should be not too difficult to use, and generic enough so that it is useful for different people/organizations. For now I don't have enough visibility about this.

Link to comment
  • 1 month later...
  • 9 months later...

Hello @jereze ,

 

This workflow might be very useful for me but I get an error when I use the workflow, debugger output is below. What can I do to make it work?

 

Starting debug for 'Salesforce'
[2019-04-12 17:03:33][STDERR: input.scriptfilter] 17:03:32 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:03:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:03:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:03:32 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:03:32 workflow.py:1628 DEBUG    Reading settings from `/Users/Ceyhun/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
17:03:32 workflow.py:2423 DEBUG    Set last run version : 0.0.2
17:03:32 workflow.py:2267 DEBUG    Workflow finished in 0.117 seconds.
[2019-04-12 17:03:36][STDERR: input.scriptfilter] 17:03:35 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:03:35 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:03:35 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:03:35 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:03:35 workflow.py:1628 DEBUG    Reading settings from `/Users/Ceyhun/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
17:03:35 workflow.py:2423 DEBUG    Set last run version : 0.0.2
17:03:35 workflow.py:2267 DEBUG    Workflow finished in 0.099 seconds.
[2019-04-12 17:03:38][ERROR: input.scriptfilter] Code 1: 17:03:36 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:03:36 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:03:36 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:03:36 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:03:36 salesforce_api.py:50 INFO     API get call: https://eu26.salesforce.com/services/data/v40.0/search/?q=FIND+{12}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+
17:03:38 salesforce_api.py:78 INFO     5Aep861JmND5bFIsaeJoNXoXlUVRs_AmYexRCMmImn9vREMKE1G.RFjImnpIzdOc6pgYZWWR9HKk1HfOJxQwkWT
17:03:38 salesforce_api.py:79 INFO     API post call: https://login.salesforce.com/services/oauth2/token
17:03:38 salesforce_api.py:84 DEBUG    {"error":"invalid_grant","error_description":"expired access/refresh token"}
17:03:38 workflow.py:2243 ERROR    API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
Traceback (most recent call last):
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/workflow/workflow.py", line 2236, in run
    func(self)
  File "salesforce_search.py", line 136, in main
    'q': "FIND {%s} IN ALL FIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email), Opportunity (Id, Name, StageName, CloseDate), Lead (Id, Name) WITH METADATA='LABELS' " % query.replace("\\", "\\\\").replace("'", "\\'")
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/salesforce_api.py", line 52, in api_call
    self.refresh_access_token()
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/salesforce_api.py", line 85, in refresh_access_token
    raise ValueError('API error when refreshing the token (%i): %s' % (r.status_code, r.text))
ValueError: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
17:03:38 workflow.py:2267 DEBUG    Workflow finished in 1.966 seconds.
[2019-04-12 17:03:40][ERROR: input.scriptfilter] Code 1: 17:03:38 workflow.py:2225 DEBUG    Workflow version : 0.0.2
17:03:38 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
17:03:38 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
17:03:38 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
17:03:38 salesforce_api.py:50 INFO     API get call: https://eu26.salesforce.com/services/data/v40.0/search/?q=FIND+{12345}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+
17:03:40 salesforce_api.py:78 INFO     5Aep861JmND5bFIsaeJoNXoXlUVRs_AmYexRCMmImn9vREMKE1G.RFjImnpIzdOc6pgYZWWR9HKk1HfOJxQwkWT
17:03:40 salesforce_api.py:79 INFO     API post call: https://login.salesforce.com/services/oauth2/token
17:03:40 salesforce_api.py:84 DEBUG    {"error":"invalid_grant","error_description":"expired access/refresh token"}
17:03:40 workflow.py:2243 ERROR    API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
Traceback (most recent call last):
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/workflow/workflow.py", line 2236, in run
    func(self)
  File "salesforce_search.py", line 136, in main
    'q': "FIND {%s} IN ALL FIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email), Opportunity (Id, Name, StageName, CloseDate), Lead (Id, Name) WITH METADATA='LABELS' " % query.replace("\\", "\\\\").replace("'", "\\'")
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/salesforce_api.py", line 52, in api_call
    self.refresh_access_token()
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.B19691F4-ECEA-46E6-85BC-0ED7E746B876/salesforce_api.py", line 85, in refresh_access_token
    raise ValueError('API error when refreshing the token (%i): %s' % (r.status_code, r.text))
ValueError: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
17:03:40 workflow.py:2267 DEBUG    Workflow finished in 1.641 seconds.

Link to comment
3 minutes ago, JJJJ said:

Hello @jereze ,

 

This workflow might be very useful for me but I get an error when I use the workflow, debugger output is below. What can I do to make it work?

 

Starting debug for 'Salesforce'
...

 

Hello @JJJJ,

 

Glad to read that this workflow could be useful.

In the logs, I see the following error: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}

Has the workflow ever worked?

Can you try to logout and login again? (using "sf > logout" and "sf > login").

Link to comment
2 hours ago, jereze said:

 

Hello @JJJJ,

 

Glad to read that this workflow could be useful.

In the logs, I see the following error: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}

Has the workflow ever worked?

Can you try to logout and login again? (using "sf > logout" and "sf > login").

 

 

@jereze It has never worked and when I try to login it gives me an error. You can find the debugger output below again.

 

[2019-04-12 19:23:02][STDERR: input.scriptfilter] 19:23:02 workflow.py:2225 DEBUG    Workflow version : 0.0.2
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
19:23:02 workflow.py:1628 DEBUG    Reading settings from `/Users/Ceyhun/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
19:23:02 workflow.py:2423 DEBUG    Set last run version : 0.0.2
19:23:02 workflow.py:2267 DEBUG    Workflow finished in 0.101 seconds.
[2019-04-12 19:23:03][STDERR: input.scriptfilter] 19:23:02 workflow.py:2225 DEBUG    Workflow version : 0.0.2
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
19:23:02 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
19:23:02 workflow.py:1628 DEBUG    Reading settings from `/Users/Ceyhun/Library/Application Support/Alfred 3/Workflow Data/jereze.salesforce/settings.json` ...
19:23:02 workflow.py:2423 DEBUG    Set last run version : 0.0.2
19:23:02 workflow.py:2267 DEBUG    Workflow finished in 0.102 seconds.
[2019-04-12 19:23:03][ERROR: input.scriptfilter] Code 1: 19:23:03 workflow.py:2225 DEBUG    Workflow version : 0.0.2
19:23:03 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
19:23:03 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
19:23:03 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
19:23:03 salesforce_api.py:50 INFO     API get call: https://eu26.salesforce.com/services/data/v40.0/search/?q=FIND+{logi}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+
19:23:03 salesforce_api.py:78 INFO     5Aep861JmND5bFIsaeJoNXoXlUVRs_AmYexRCMmImn9vREMKE1G.RFjImnpIzdOc6pgYZWWR9HKk1HfOJxQwkWT
19:23:03 salesforce_api.py:79 INFO     API post call: https://login.salesforce.com/services/oauth2/token
19:23:03 salesforce_api.py:84 DEBUG    {"error":"invalid_grant","error_description":"expired access/refresh token"}
19:23:03 workflow.py:2243 ERROR    API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
Traceback (most recent call last):
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/workflow/workflow.py", line 2236, in run
    func(self)
  File "salesforce_search.py", line 136, in main
    'q': "FIND {%s} IN ALL FIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email), Opportunity (Id, Name, StageName, CloseDate), Lead (Id, Name) WITH METADATA='LABELS' " % query.replace("\\", "\\\\").replace("'", "\\'")
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/salesforce_api.py", line 52, in api_call
    self.refresh_access_token()
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/salesforce_api.py", line 85, in refresh_access_token
    raise ValueError('API error when refreshing the token (%i): %s' % (r.status_code, r.text))
ValueError: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
19:23:03 workflow.py:2267 DEBUG    Workflow finished in 0.604 seconds.
[2019-04-12 19:23:04][ERROR: input.scriptfilter] Code 1: 19:23:04 workflow.py:2225 DEBUG    Workflow version : 0.0.2
19:23:04 workflow.py:2633 DEBUG    Got password : jereze.salesforce:access_token
19:23:04 workflow.py:2633 DEBUG    Got password : jereze.salesforce:refresh_token
19:23:04 workflow.py:2633 DEBUG    Got password : jereze.salesforce:instance_url
19:23:04 salesforce_api.py:50 INFO     API get call: https://eu26.salesforce.com/services/data/v40.0/search/?q=FIND+{login}+IN+ALL+FIELDS+RETURNING+Account+(Id%2C+Name%2C+Type)%2C+Contact+(Id%2C+Name%2C+Email)%2C+Opportunity+(Id%2C+Name%2C+StageName%2C+CloseDate)%2C+Lead+(Id%2C+Name)+WITH+METADATA%3D'LABELS'+
19:23:04 salesforce_api.py:78 INFO     5Aep861JmND5bFIsaeJoNXoXlUVRs_AmYexRCMmImn9vREMKE1G.RFjImnpIzdOc6pgYZWWR9HKk1HfOJxQwkWT
19:23:04 salesforce_api.py:79 INFO     API post call: https://login.salesforce.com/services/oauth2/token
19:23:04 salesforce_api.py:84 DEBUG    {"error":"invalid_grant","error_description":"expired access/refresh token"}
19:23:04 workflow.py:2243 ERROR    API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
Traceback (most recent call last):
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/workflow/workflow.py", line 2236, in run
    func(self)
  File "salesforce_search.py", line 136, in main
    'q': "FIND {%s} IN ALL FIELDS RETURNING Account (Id, Name, Type), Contact (Id, Name, Email), Opportunity (Id, Name, StageName, CloseDate), Lead (Id, Name) WITH METADATA='LABELS' " % query.replace("\\", "\\\\").replace("'", "\\'")
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/salesforce_api.py", line 52, in api_call
    self.refresh_access_token()
  File "/Users/Ceyhun/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.C0B19BE3-EAF6-495A-A013-653D32CDF126/salesforce_api.py", line 85, in refresh_access_token
    raise ValueError('API error when refreshing the token (%i): %s' % (r.status_code, r.text))
ValueError: API error when refreshing the token (400): {"error":"invalid_grant","error_description":"expired access/refresh token"}
19:23:04 workflow.py:2267 DEBUG    Workflow finished in 0.558 seconds.

 

Edited by JJJJ
Link to comment

Hello @JJJJ,

 

I was not able to reproduce your issue.

In the debugger output, there is not the part I'm interested in.

 

Can you again log out and log in, then type the command "sf > debug" and send me the file (or the full content) that you will find in the directory?

You can send it in a private message if you prefer.

 

Jeremy

Link to comment
15 hours ago, jereze said:

Hello @JJJJ,

 

I was not able to reproduce your issue.

In the debugger output, there is not the part I'm interested in.

 

Can you again log out and log in, then type the command "sf > debug" and send me the file (or the full content) that you will find in the directory?

You can send it in a private message if you prefer.

 

Jeremy

 

Hi @jereze,

 

I logged in and logged out as you say, then I got the debug report. You can find the link below.

 

https://we.tl/t-aDmhm6yJwT

 

 

Link to comment

Hi @JJJJ,

 

I have studied the bug report.

No particular error during the authentication with Salesforce. I cannot explain the API error when refreshing the token (400).

However, I found another error: No such column 'Type' on entity 'Account'.

That's exactly the issue that got @AcidAlfred one year ago. He solved the issue making the field `Type` visible.

Can you try to do the same?

A next version of the workflow could fix this issue (=work without this field).

 

On 4/27/2018 at 2:23 PM, AcidAlfred said:

@jereze  Thanks for your help and excuse the late feedback. Indeed the "type" field in our org was hidden. After making it visible the search is now working.  

 

Link to comment
20 hours ago, jereze said:

Hi @JJJJ,

 

I have studied the bug report.

No particular error during the authentication with Salesforce. I cannot explain the API error when refreshing the token (400).

However, I found another error: No such column 'Type' on entity 'Account'.

That's exactly the issue that got @AcidAlfred one year ago. He solved the issue making the field `Type` visible.

Can you try to do the same?

A next version of the workflow could fix this issue (=work without this field).

 

 

Hi @jereze

 

I couldn't find "type" column to add in account section in our system, perhaps we do not have that in my organization. I guess I will wait for the next version. 

 

Thank you very much for your help. I will be looking forward to the next version.

Edited by JJJJ
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...