• Chuck Ramsey
  • NEWBIE
  • 5 Points
  • Member since 2015
  • Wolters Kluwer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
My Org is Spring '20 (API V48). According to the Apex documentation, the ConnectApi class has several methods to query Managed Content.  I'm trying to use getManagedContentByTopics with no success so far.

According to the Apex guide this should work:
ConnectApi.ManagedContentVersion Collection mcvc = ConnectApi.getManagedContentByTopics(networkId, 'My Topic', 0,1,'MyContentType);

I consistently get the error "Variable does not exist: ConnectApi" with a line number and column number corresponding to ConnectApi.getManagedContentByTopics.

What have I missed?
I'm using the NavigationMixin in a LWC, navigating to an object page (standard__ObjectPage) to create a new record for a custom object.. I call getRecordCreateDefaults and generateRecordInputForCreate from lightning/uiRecordApi to create an object with default field values.  After updating two additional fields in the default values object, I conver the object to a JavaScript Map and pass the Map to encodeDefaultFieldValues to set the default values for my Navigate call.  It appears that encodeDefaultFieldValues will not encode picklist defaults.  I thought it might have been a problem with the picklist value being multiple words separated by spaces (e.g., 'Minor problem. I can continue working'), however, when I replaced the picklist values with single words, the problem persists.  My new object form does not show the default value for the picklist field.
Salesforce uses a URL like "https://mycommunity/secur/logout.jsp?retUrl=https%3A%2F%2fmycommunityurl%2FCommunitiesLanding". If I use the force:navigateToUrl event with a similar URL, navigateToUrl sees the address as an absolute URL and always opens it in a new tab/window; the tab from which I click the Logout option in my User Profile Menu remains open and usable. Salesforce says that window.location won't work in Lightning and my experience supports that assertion. How does the User Profile Menu component supplied with Napili implement logout?

I know I've got the composition of the URL correct -- if I enter the URL in my browser I get the expected behavior:
  • If I'm logged in to the community as myself, I get logged out and returned to the login page.
  • If I'm logged in as an extranl (customer) user, I get sent back to the Contact page for that user.
Whenever someone requests membership in a private CollaborationGroup that I own, I get an email with a button marked 'View Request'. Clicking the button, however, just takes me to the Group page in our Community. The Napili template doesn't appear to contain a page to handle these requests. The URL associated with the View Request button looks like this:

https://mysalesforcecommunityurl/s/<groupId>?fromEmail=1&s1oid=<myOrgId>&s1nid=<networkId>&s1uid=<groupownerid>&s1ext=0&emkind=chatterGroupMembership&emtm=<13-digit number>&u=<requesterId>&data=<long encoded string>&sdata=<another long encoded string>&reserved=0

The URL parameters contain a lot of information; some of it is readily decoded:
  • the CollaborationGroup Id
  • a fromEmail flag (set to 1) -- what's the purpose of this flag?
  • my Org Id (s1oid)
  • the Community (Network) Id (s1nid)
  • the group owner Id (s1uid)
  • emkind (?) -- chatterGroupMembership
  • the Id of the User requesting membership (u)
The remaining parameters -- emtm, s1ext, data, sdata, and reserved  -- are a mystery to me. I'd like to be able to decode the URL paramters so that I can create a page to handle these requests, unless the page already exists in the Napili template and I couldn't identify it.
 
We have Salesforce Ultimate, Summer 2015 release. My login has adminstrator privileges and API is enabled.

I am developing a Windows forms application in C# that will use the REST Analytics API to capture report information. I am using the OAuth 2.0 User Agent flow to obtain an authentication token. I have registered my app as a Connected App, with a callback URI of sfrr:oauth2. I monitor the URLs during authentication and intercept any calls to that uri. In the Connected App setup, I selected "full" and "refresh_token, offline_access" as OAuth Scopes.

 After some initial difficulty, I am now regularly receiving my access token. However, when I tried to use that token to retreive a report, I got the 401 status (Not Authorized). At that point, I went back to the sample queries from the REST API Developer's Guide and started excuting them. The first query in the form <instance_url>/services/data/ returns a list of API versions, as expected. The next call is to <instance_url>/services/data/v34.0/. I should get a list of available resources, but I get the Not Authorized response instead. I am passing my access token in the request header using "Authorization:Bearer <access token>" and <instance_url> is the URL returned iin my OAuth User Agent results.

I saw -- once and could not find it again -- a forum response that gave the name and email address for a contact in Salesforce if your organization cannot access even though access should otherwise be available. Is that still a problem? Is there somethig else I'm missing here? Suggestions and enlightenment gratefully accepted.

 
My Org is Spring '20 (API V48). According to the Apex documentation, the ConnectApi class has several methods to query Managed Content.  I'm trying to use getManagedContentByTopics with no success so far.

According to the Apex guide this should work:
ConnectApi.ManagedContentVersion Collection mcvc = ConnectApi.getManagedContentByTopics(networkId, 'My Topic', 0,1,'MyContentType);

I consistently get the error "Variable does not exist: ConnectApi" with a line number and column number corresponding to ConnectApi.getManagedContentByTopics.

What have I missed?
I can't get a test class to work for a Trigger that is only looking for when a Case Comment is Updated.

trigger validation on CaseComment (before update) {  
    if(Trigger.isUpdate){
        for(CaseComment caseCmt : Trigger.new){
            if(caseCmt.CreatedById != System.UserInfo.getUserId()){
                caseCmt.addError('You can not edit Someone else\'s Comment');
            }
        }
    }
}

Any Help/Advice would be appreciated:)
Salesforce uses a URL like "https://mycommunity/secur/logout.jsp?retUrl=https%3A%2F%2fmycommunityurl%2FCommunitiesLanding". If I use the force:navigateToUrl event with a similar URL, navigateToUrl sees the address as an absolute URL and always opens it in a new tab/window; the tab from which I click the Logout option in my User Profile Menu remains open and usable. Salesforce says that window.location won't work in Lightning and my experience supports that assertion. How does the User Profile Menu component supplied with Napili implement logout?

I know I've got the composition of the URL correct -- if I enter the URL in my browser I get the expected behavior:
  • If I'm logged in to the community as myself, I get logged out and returned to the login page.
  • If I'm logged in as an extranl (customer) user, I get sent back to the Contact page for that user.
Is it possible to run Apex code under a different user than the logged in one?

So someone has logged in and they kick off some Apex code, but I need that specific method to run under an admin user? Is that possible?

Thanks.