Skip to main content

Posts

Salesforce admin gotchas

After coming across some of these for the hundredth time, I've decided to keep a list of bizarre inconsistencies / gotchas in Salesforce.


Editable list views for certain objects don't allow editing of record owner field, even though certain object types (e.g. Cases) have a "Change owner" or "Assign" option right there on the list view which does the same thing, so something exactly like this is obviously already implemented.You can mass transfer ownership of accounts, but not contacts. It's because of this.The force.com cli's export-to-csv functionality (force query --format:csv) creates a file that its own CSV parsing functions consider invalid if you try to re-import it (force bulk update whatevs.csv).Adding a custom field to a standard object does not add it to any report types for that object.  But adding a custom field to a custom object does.

Recent posts

"A section using 'configSource' may contain no other attributes or elements" error after installing Application Insights

After installing the Application Insights nuget package to an Umbraco solution, you'll get this error:

A section using 'configSource' may contain no other attributes or elements

<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
     <log4net configSource="config\log4net.config">
         <root>
             <level value="ALL" />
             <appender-ref ref="aiAppender" />
Source File: \project\web.config

This happens because part of the Application Insights installation process adds a <log4net> section to web.config.  Which would make sense, except Umbraco already has a <log4net> section in /config/log4net.config.  So as you can imagine, the solution is to manually move everything its added into that file. Unfortunately you can't just copy/paste the whole lot, but it's not particularly complicated:


Move <appender-ref ref="aiAppender" /> into the lo…

Using the Force.com CLI and Powershell

Deleting: First, write the list of records to a file (you could just save to a variable but it can come in handy to keep a list of IDs when modifying records)

force query "SELECT Id FROM Object__c WHERE Field__c = 'Whatever'" | Out-File .\ids_to_delete.csv

If it's not a big list, just pipe that back into a CSV object and iterate over it, deleting each one with "force record delete"

Import-Csv .\ids_to_delete.csv | % { force record delete Object__c $_.Id }

It's not very fast, so if there's a lot of them you'll need to use the bulk API.  First remove the quotes from the CSV, no idea why, but "force bulk" hates them for some reason.  Then call it like this:

force bulk delete Object__c .\ids_to_delete.csv

If you just have a medium-sized list of IDs to delete and they're not in a CSV (e.g. copypasta from elsewhere), just paste them right into the command line as one big string and .Split() them, like this:

"axxx000000xxxxxAAA axxx…

IIS HTTP Error 500.19, Error Code 0x8007000d

I probably come across this error at least once per year. Ran into it again today when setting up a website to host locally in IIS, on a computer I don't use much.

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:
Module   IIS Web Core
Notification   Unknown
Handler   Not yet determined
Error Code   0x8007000d

Config Source:
   -1:
    0:


Microsoft's documentation for that error code helpfully points out:

"This problem occurs because the ApplicationHost.config file or the Web.config file contains a malformed XML element."

Well that clears it up. Just remove the malformed XML element on line 0...

Except that the site runs just fine on other systems, and even in IIS Express on the same machine that's causing the error, so clearly there's no "malformed XML".  Anyway, it turns out that if your web.config has a section for something li…

Umbraco's TinyMCE error: "Cannot read property 'parentsRequired' of undefined"

If you find that the "Formats" list in an Umbraco RTE refuses to open, and the Javascript console contains this error:

"Cannot read property 'parentsRequired' of undefined"

Check the stylesheet that the RTE is using.  In my case, adding this style had triggered the issue:

/**umb_name:Small*/
small{}

Although there's nothing wrong with this style itself, the problem is in what TinyMCE considers to be "valid" HTML elements.  Why is "small" not valid?  No idea!  But you can fix this by opening /config/tinyMceConfig.cfg, finding the <validElements> section and appending this:
,small[class]
And that's it!  You can probably substitute "[class]" with other attributes if you need to, or even just [*].  I'm not really sure what all the implications of that are (let me know if you find out), so I just went with [class] like some of the other properties have.

Credit to Eric Schrepel for helping me figure this one out at h…

Using Umbraco ModelsBuilder

Firstly, make sure the following properties are set in your solution's top-level web.config to enable the models builder:

<add key="Umbraco.ModelsBuilder.Enable" value="true"/>
<add key="Umbraco.ModelsBuilder.ModelsMode" value="LiveAppData"/>

I like the "LiveAppData" mode, but you should experiment with the others from the list in the ModelsBuilder docs here.  Generate your model classes, and include them in the VS Solution.
Unless you're on a brand new project, any existing views will need to be modified.

Model class inheritance Change instances of
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
to
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.ModelName>

Property Access Change instances of @Umbraco.Field("propertyAlias") to @Model.PropertyAlias Note that the ModelsBuilder converts property aliases to PascalCase instead of camelCase
Rendering Grid HTML Change instances of
@CurrentPage.GetGrid…

Powershell as a Visual Studio External Tool

It's handy to be able to open Powershell at the current solution directory, e.g. for invoking scripts or git commands etc.
Click the Tools menu  -> External Tools -> Add
Title: Powershell, or whatever you want
Command: your PS directory, e.g C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -ExecutionPolicy RemoteSigned -NoExit -Command "Set-Location '$(SolutionDir)' | Clear-Host"
Initial directory: $(SolutionDir)