• Ken Koellner 1
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 16
    Replies
I have some Apex code that using Message.singleEmailMessage instances and Messaging.sendEmail() to send mail.   I enterstand how Contacts can be flagged with a bounced email address.  It appears that in some scenarios, when apex code sends email to a Contact, I get the Exception and in other scenarios, I do not.  I'm trying to understand why.  I even capture debug logs of the emails sent that generated a bounce and tried it in anonymous apex and do not get the exception.  I haven't determined the difference.  Below is an example of a request (with the debug, subject, and body members removed for brevity).  Sending this doesn't yield an Exception from anonymous Apex.  When the send mail was run from an update trigger via apex code in a trigger handler classes, I do get the Exception.  Anyone know what could be different?
 
{
  "bccAddresses" : null,
  "bccSender" : false,
  "ccAddresses" : null,
  "charset" : null,
  "emailPriority" : "Normal",
  "entityAttachments" : null,
  "fileAttachments" : null,
  "inReplyTo" : null,
  "numRecipients" : 2,
  "optOutPolicy" : "SEND",
  "orgWideEmailAddressId" : null,
  "references" : null,
  "replyTo" : null,
  "saveAsActivity" : true,
  "senderDisplayName" : null,
  "sentDate" : null,
  "targetObjectId" : "0031I000002FZaJQAW",
  "templateId" : null,
  "templateName" : null,
  "toAddresses" : [ "spavlova@uog.com" ],
  "treatBodiesAsTemplate" : false,
  "treatTargetObjectAsRecipient" : true,
  "useSignature" : true,
  "userMail" : false,
  "whatId" : "a041I00002v0czMQAQ"
}

 
I'm just starting to write Lightning components that I can put on record pages and am getting the hang of displaying data.  But I'd like to be able to edit some custom data.  What I'd really like to do is add a section on the standard edit page for an object, the modal page that comes up when you select the Edit action.  Then on that page, have a custom section on the bottom with some of my own information from other objects.  The user can save or cancel and my controller would be notified of the save event and save the appropriate information.

Anyone know if there's a way to do that or a suggesting on how to architect a page such that fields from more than one record are edited at the same time?  I'd like to not have to rewrite the code for the standard object and only have code for my custom object.
Under personnal preference, you see timezone Names like --

Line Is. Time (Pacific/Kiritimati)
Phoenix Is.Time (Pacific/Enderbury)
Tonga Time (Pacific/Tongatapu)
...
Eastern Daylight Time (America/Indiana/Indianapolis)
Eastern Daylight Time (America/New_York)

But User.TimeZoneSidKey has only the ISO timezone name like "America/New_York".

Is there any place in SF where Apex code can get the fullname like like "Eastern Daylight Time (America/New_York)"?
 
We have need to get the date format for the User's locale.  I wrote the Apex below.  It would return "MM/DD/YYYY" with locale set to US English and "DD/MM/YYYY" for Locale set to UK English.  Anyone have a more elegant solutin to get that string?  I didn't see any methods in Apex other than to get Locate like EN_US which would require a table lookup or case statement to handle every possible locale.
 
Date myDate = Date.newInstance(2018,12,31);

String myStr = myDate.format();
myStr = myStr.replace('2018','YYYY');
myStr = myStr.replace('12','MM');
myStr = myStr.replace('31','DD');

System.debug(myStr);

 
I have several orgs on Summer '17.  In most, the "Create and Customize Reports" is called EditReports in profile files.  And if I look at the metadata of the profile object, the field is PermissionEditReports.

In one org, the same permissions is called CreateCustomizeReports and in the metedata for profile PermissionCreateCustomizeReports.

That makes profiles non-deployable between the orgs.  I do not know why one org has a different API Name for that permission when the lable is the same.  I can only think some org-wide setting is different.

Anyone know why one org with have CreateCustomizeReports as the API name for that permission while the other is EditReports?

 
I'm trying to deploy a profile from one org to another.  Some of the permissions have different internal names so the profiles won't deploy.  For example, Create and Customize Reports is "EditReports" in one org but "CreateCustomizeReports" in the other.  So the profile file won't deploy.  Anyone know how to resolve that?

This kinda of stuff can be such a time suck in Salesforce.
I'm trying to get debug logs when a non-browser (Twillio) access VF pages implemented on Sites (that are coded to deliver XML).  I'm not getting debug logs.  I did some searching and found release notes from Winter '17 that say for sites guest users, a cookie must be set in order to get debug logs.  That works fineina browser.  I tried setting a cookie the controller constructor (see below) that delivers the page but that didn't work.  Maybe because Twillio isn't sending the cookie back.  And even if that might work, the call that came in would not yet have the cookie so I wouldn't have a debug log.

  I haven't figured out a work around.  I'm wondering if anyone else has.
Cookie debugCookie = ApexPages.currentPage().getCookies().get('debug_logs');
        if (debugCookie == null) {
            debugCookie = new Cookie('debug_logs','debug_logs','.force.com',300,true);
        }
        ApexPages.currentPage().setCookies(new Cookie[]{debugCookie});

 

We have a use case where we want an action to take place on a record and trigger an action on another record.  But the user profile will have no CRUD access on the other record.  We have to enforce CRUD security.  So what I want to do is when an update fires on the first record have some process run as a different user and update the second record.  If it's a trigger, it will run as the original user.  If it's a workflow, it will also run as the original user.  I need it to specifcally run as a different user.  Forget about Apex running in system mode or without sharing.  It specifically has to be a different user.

Can you think of any automation technology in SF that will do that?

The only thing that I can think of is to have Batch apex run periodically as the other user and scan for chages. But I really don't want to keep the very limited batch resources buy.

Ideas?
 

Please no work arounds.  It abosuluely positively has to run as a different user.


If you enforce object level CRUD in Apex code for the Site Guest User, will Event not be creatable?  It looks like there is no way to check access for Event.   I found the comment in the manual "With the public access settings you're allowed to set full create/read/update/delete (CRUD) permissions for all custom objects, and read and create on most standard objects. There are three standard objects – Products, Pricebooks, and Ideas – that are exposed as read only.".  That would imply so but there's no check box to check for that object on the profile.

I wrote the test below --
 
@isTest(seeAllData=true)  class KKExperSecurityTest {


  private static TestMethod void checkGuestUserEventPermissionTest()  {
    
    User myUser = [ select id from User where username = 'mysiteuser@mydevscheduler-developer-edition.na40.force.com'];

    Boolean myBoolean = Schema.Event.getSObjectType().getDescribe().isCreateable();
    System.debug('running as system user -- ' + myBoolean);
 

    system.runAs(myUser) {      
        
      myBoolean = Schema.Event.getSObjectType().getDescribe().isCreateable();
      System.debug('running as guest user -- ' + myBoolean);
 
    }  
  }   


}
And it printed--
19:24:44.0 (10012796)|USER_DEBUG|[9]|DEBUG|running as system user -- true
19:24:44.0 (40760779)|USER_DEBUG|[15]|DEBUG|running as guest user -- false


 
I'm trying to generate a soap header for a web service callout via an wsdl2apex generated stub class like --
<env:Header>
                <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                                <UsernameToken>
                                                <Username>myUserName</Username>
                                                <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</Password>
                                </UsernameToken>
                </Security>
</env:Header>

The critical factor is inserting the Type attribute on the password element.  The answer of how to inject the Security info is clearly answered in my forums.  But I haven't found any answer to the problem of injecting the type element.  I know there is one post from many years ago saying there's no way to send both a value and an attribute for a simple element.  I do not know if that is still true.  I'd loved to find a work around for this issue.

If you know a work-around for the specific issue of sending that Type attribute with the password, please please please respond.

Not response required for related question of how to add the soap header in general.  No response required mentioning  old threads that don't specifically address and the Type attribute issue on password.
I'm coding a Lighning component.  I can allow the user to navigate to a record with e.force:navigateToSObject but that will always load it in the current tab.  

If I want the user to optionally (or always) open the record in a new tab, is there a preferred method of doing it?  Or is it even advisable.

I thought maybe including a regular HTML hyprlink like -- /one/one.app#/sObject/0066A000002ycK8QAI/view would do it.  Then the user could right-lick and open in new tab.  I don't know if there's a better way.  Or perhaps because mobile apps like Salesforce1 always operate in one window, whether it might not be a could idea to even try that (the link would then launch the user's mobile browser and the record would open there rather than in the SF1 app).

Thoughts?

-Ken
 
Trying the Input Data Using forms trailhead and doing the "Create a Form to Enter New Items" at the end of one module.  Getting error --

"Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't have an attribute named 'newItem' of type Camping_Item__c with a default sObject."

MY campingList.cmp file begins--
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c" default = "{ 'Quantity__c' : '0'
                                                                      , 'Price__c'   : '0' }"/>
     <aura:attribute name="items" type="Camping_Item__c[]"/>
Any Idea what could be wrong?

I am using a dev org with a Namespace.  (I thought you had to do do Lighning trailheads.)

 
I know in the order of operations, triggers fire before workflows, then if there are field updates, the record is updated and triggers fire again.

Most SF developers and admins are of the opinion that you should do as much declaratively via Workflows, Process Builder, etc. and not use triggers and Apex code unless the use case is such that it cannot be implemented via declarative features.

But when you do need triggers, if you have field updates, you have to be very careful that they don't interfere with each other and have to consider any bad effectst that could happen from a trigger fireing more than once.

So I'm wondering if perhaps it's best to implement with a pattern that once triggers are needed, then avoid doing field updates via declarative features and do all field assignments in the triggers.  The downside is admins can no longer define simpler features.  But the upside is that all the record assignments are then in one carefully controlled stream of code executed by the trigger.

Thoughts?
 
I haven't used the feature where test data in Apex Test methods is load from .csv files in static resources.  I would assume it just does simple field assignments.  I'm curious if there's a way to set lookup/master-detail relatinship fields during the load (like an upsert in DataLoader that can use External Id fields).

I would think if you want to load parent table related child , you'd that functionality like that.  You might be able to work around by doing the loads, then running some setup code in Apex to link the objects using the natural keys to build a map and then set an Id.  But that would only work for lookup, not master-detail.

 
I have (what I believe is) a free developer edition.

Is it possible to implement sites on this org?

I see Apex and Pages under Development along with all the other stuff but I don't see sites anywhere.

Anyone know if this can be done?
I have several orgs on Summer '17.  In most, the "Create and Customize Reports" is called EditReports in profile files.  And if I look at the metadata of the profile object, the field is PermissionEditReports.

In one org, the same permissions is called CreateCustomizeReports and in the metedata for profile PermissionCreateCustomizeReports.

That makes profiles non-deployable between the orgs.  I do not know why one org has a different API Name for that permission when the lable is the same.  I can only think some org-wide setting is different.

Anyone know why one org with have CreateCustomizeReports as the API name for that permission while the other is EditReports?

 
Under personnal preference, you see timezone Names like --

Line Is. Time (Pacific/Kiritimati)
Phoenix Is.Time (Pacific/Enderbury)
Tonga Time (Pacific/Tongatapu)
...
Eastern Daylight Time (America/Indiana/Indianapolis)
Eastern Daylight Time (America/New_York)

But User.TimeZoneSidKey has only the ISO timezone name like "America/New_York".

Is there any place in SF where Apex code can get the fullname like like "Eastern Daylight Time (America/New_York)"?
 
We have need to get the date format for the User's locale.  I wrote the Apex below.  It would return "MM/DD/YYYY" with locale set to US English and "DD/MM/YYYY" for Locale set to UK English.  Anyone have a more elegant solutin to get that string?  I didn't see any methods in Apex other than to get Locate like EN_US which would require a table lookup or case statement to handle every possible locale.
 
Date myDate = Date.newInstance(2018,12,31);

String myStr = myDate.format();
myStr = myStr.replace('2018','YYYY');
myStr = myStr.replace('12','MM');
myStr = myStr.replace('31','DD');

System.debug(myStr);

 
I'm trying to get debug logs when a non-browser (Twillio) access VF pages implemented on Sites (that are coded to deliver XML).  I'm not getting debug logs.  I did some searching and found release notes from Winter '17 that say for sites guest users, a cookie must be set in order to get debug logs.  That works fineina browser.  I tried setting a cookie the controller constructor (see below) that delivers the page but that didn't work.  Maybe because Twillio isn't sending the cookie back.  And even if that might work, the call that came in would not yet have the cookie so I wouldn't have a debug log.

  I haven't figured out a work around.  I'm wondering if anyone else has.
Cookie debugCookie = ApexPages.currentPage().getCookies().get('debug_logs');
        if (debugCookie == null) {
            debugCookie = new Cookie('debug_logs','debug_logs','.force.com',300,true);
        }
        ApexPages.currentPage().setCookies(new Cookie[]{debugCookie});

 
I'm coding a Lighning component.  I can allow the user to navigate to a record with e.force:navigateToSObject but that will always load it in the current tab.  

If I want the user to optionally (or always) open the record in a new tab, is there a preferred method of doing it?  Or is it even advisable.

I thought maybe including a regular HTML hyprlink like -- /one/one.app#/sObject/0066A000002ycK8QAI/view would do it.  Then the user could right-lick and open in new tab.  I don't know if there's a better way.  Or perhaps because mobile apps like Salesforce1 always operate in one window, whether it might not be a could idea to even try that (the link would then launch the user's mobile browser and the record would open there rather than in the SF1 app).

Thoughts?

-Ken
 
Trying the Input Data Using forms trailhead and doing the "Create a Form to Enter New Items" at the end of one module.  Getting error --

"Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't have an attribute named 'newItem' of type Camping_Item__c with a default sObject."

MY campingList.cmp file begins--
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c" default = "{ 'Quantity__c' : '0'
                                                                      , 'Price__c'   : '0' }"/>
     <aura:attribute name="items" type="Camping_Item__c[]"/>
Any Idea what could be wrong?

I am using a dev org with a Namespace.  (I thought you had to do do Lighning trailheads.)

 
I have created a lightning component and I wanted to display it in account tab in detail record page, so for that i created a tab just beside the account detail tab and drag an dropped the component there.
It workers fine in salesforce lighting but when i tried to login through salesforce 1 mobile app that tab itself is not visible and also the component is not visible.can anyone tell me why this is happenening ?
 
I am trying to fetching my force.com site domain I have created. Gone through lot of internet contents but find no where a solution to fetch the complete Domain/Default site url. Possible is to query urlPathPrefix and salesforce.com domain, but not the complete force.com domain I have created.

for example: ***-developer-edition.ap2.force.com
                   ***-developer-edition.na3.force.com
                   ***-developer-edition.XYZ.force.com

could be fetched properly!

Hello. I have a Force.com Site domain configured, and a Force.com site. The Force.com Site domain shows under Domains > My Domains. I can query the Site object, and it has the proper SubDomain value.

According to the docs, I should be able to query the Domain object and find this Force.com Sites domain. Also, there should be a DomainSite record linking the Site to the Domain. Right?

I query both the Domain and DomainSite objects (as a System Administrator), and both queries return no results.

I want to check, from Apex code (or using the Metadata API or something) whether there's a Force.com Sites domain set already on the org, and it's sub-domain component. Even when there are no sites created (I guess in that case I could query for a Site record with Type = Force.com Site, and use the SubDomain value?).

The final objective here, is being able to programatically create a Force.com Site. We intend to use the Metadata API for doing this.

Any ideas? Thanks!

  • September 28, 2016
  • Like
  • 1
Can any one please suggest me how to achieve the Salesforce CI to retrieve the metadata from one org and deploy into another org.
I'm trying to set up a web service callout upon creation of a new sfLma__License__c object. I've set up an after insert trigger on the object, and have a call to an @future method for the web service callout in a separate class. 

For whatever reason, the trigger never seems to actually execute. It executes well if I manually create the license record, but licenses that get created by the LMA from AppExchange app installs do not execute the trigger.

I don't quite know how to debug this issue either, as the LMA user isn't a user that we can view debug logs for.

Anyone have any ideas?
I am attempting to extract metadata from one org and deploy to another and I receive the message 
profiles/Standard.profile -- Error: Unknown user permission: EditReports
for .profile XML files that contain
<userPermissions>
        <enabled>true</enabled>
        <name>EditReports</name>
    </userPermissions>
I've searched through the Release notes for Summer '13, Winter '14, Spring '14 and Summer '14 and cannot find any reference for a change to this user permission, although I can see that there are new User Permissions like ManageReportsInPubFolders although this looks more like the old EditPublicReports.

Can anyone point me towards documentation or references that describe the current User Permissions by their API names in the metadata API? Or the release in which this was changed?

Hi,

 

is there a way to authenticate an application for using the salesforce rest api with just the normal username / password credentials from

the basic http authentication?

I know thats not safe but its just for testing the functionality of my application.

 

best regards

Elmar

  • June 27, 2012
  • Like
  • 0

Hi all.

 

I am trying to connect from Apex to an external WebService that requires the use of ws-security. I have discovered that this is not directly supported by Apex, but a suggested solution was to manually edit the WDSL document to include the ws-security header information.

 

I have been trying to do this without much luck, and was wondering if anyone out there had a simple example of what I need to inject into the WSDL, and where?

 

My thanks in advance,

Ivar

  • December 21, 2010
  • Like
  • 0

Hi,

 

My webservice expects the security header to have username, password, password type and timestamp.

I am stuck with an issue and would like some assistance.

 

My Webservice code is

    public static void setupSecurity(Object service) {

        org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(service);

        org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

        Map<String, Object> outProps= new HashMap<String, Object>();

        outProps.put(WSHandlerConstants.ACTION,

                WSHandlerConstants.USERNAME_TOKEN + ' ' + WSHandlerConstants.TIMESTAMP);

        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);

        outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());

        outProps.put(WSHandlerConstants.USER, "Admin");

        PhaseInterceptor<SoapMessage> wssOut = new WSS4JOutInterceptor(outProps);

        cxfEndpoint.getOutInterceptors().add(wssOut);

        cxfEndpoint.getOutInterceptors().add(new SAAJOutInterceptor());

    }

 

As PasswordType also has to be sent as part of SOAP header i updated the WSDL.

Below is partial WSDL

 <xsd:schema elementFormDefault="qualified" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" >
     <xsd:element name="Security" type="s3:SecurityHeaderType"/>
       <xsd:complexType name="SecurityHeaderType">
        <xsd:sequence>
          <xsd:element minOccurs="1" maxOccurs="1" name="UsernameToken" type="s3:UsernameToken"/>
          <xsd:element minOccurs="1" maxOccurs="1" name="TimeStamp" type="s3:TimeStamp"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="UsernameToken">
        <xsd:sequence>
          <xsd:element minOccurs="0" maxOccurs="1" name="Username" type="xsd:string"/>
          <xsd:element  minOccurs="1" maxOccurs="1" name="Password">
           <xsd:complexType>
             <xsd:simpleContent>
                 <xsd:extension base="xsd:string">
                       <xsd:attribute name="Type" type="xsd:string"/>
                     </xsd:extension>
              </xsd:simpleContent>
          </xsd:complexType>
           </xsd:element>         
         </xsd:sequence>
      </xsd:complexType>
    
      <xsd:complexType name="TimeStamp">
        <xsd:sequence>
          <xsd:element minOccurs="0" maxOccurs="1" name="Created" type="xsd:dateTime"/>
          <xsd:element minOccurs="0" maxOccurs="1" name="Expires" type="xsd:dateTime"/>
        </xsd:sequence>
      </xsd:complexType>

    </xsd:schema>

 

I added attribute Type for the Password element in WSDL. The Webservice is using PasswordText as the type.

 

Below is the generated code of the security class

public class OasisSecurity {
    public class Password_element {
        public String Type_x;
        private String[] Type_x_att_info = new String[]{'Type'};
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class TimeStamp {
        public DateTime Created;
        public DateTime Expires;
        private String[] Created_type_info = new String[]{'Created','http://www.w3.org/2001/XMLSchema','dateTime','0','1','false'};
        private String[] Expires_type_info = new String[]{'Expires','http://www.w3.org/2001/XMLSchema','dateTime','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'Created','Expires'};
    }
    public class UsernameToken {
        public String Username;
        public OasisSecurity.Password_element Password;
        private String[] Username_type_info = new String[]{'Username','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','Password_element','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'Username','Password'};
    }
    public class SecurityHeaderType {
        public OasisSecurity.UsernameToken UsernameToken;
        public OasisSecurity.TimeStamp TimeStamp;
        private String[] UsernameToken_type_info = new String[]{'UsernameToken','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','UsernameToken','1','1','false'};
        private String[] TimeStamp_type_info = new String[]{'TimeStamp','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','TimeStamp','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'UsernameToken','TimeStamp'};
    }
}

 

The problem i am facing is, i am able to assign value to the Type_x of the Password_element class.

But i am unable to set the value to the Password .

 

This is how the header part of my request looks like

<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header><Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>Administrator</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" /></UsernameToken><TimeStamp><Created>2010-07-28T17:42:25.966Z</Created><Expires>2010-11-25T17:42:25.966Z</Expires></TimeStamp></Security></env:Header>

 And it can be seen in header that i am just able to pass the attribute Type of Password tag and unable to set Value for Password.

 

I am getting the below error message after the webservice callout.

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Fault occurred while processing. faultcode=ns1:client faultactor=

 

Any help on this will be highly appreciated.