Should we create custom pages for all objects? - salesforce

I noticed that salesforce doesn't allow to override control function for all objects.
Say if you want to do something whenever objects get saved there is no way to attach the action
unless you create a custom page and include either standard controller or extension. Or if you want
to add the same meta-tag on all pages I run into this limitation. Is there better way to do this?

Generally - no. Roughly speaking if Salesforce doesn't allow you to do something it usually means there's pretty good hint you're doing in it wrong. I realize it sounds like I'm a fanboy but in reality - can you expand your question with concrete example why would you want to do something like that? For example governor limits are evil, annoying etc. - but they force you to write effective code that doesn't strain the database too much.
if you want to do something whenever objects get saved
That's what triggers are for. Ask yourself a question if the "action" you need to make should happen only from web UI or also when performed from API (mass data load, a smartphone application etc).
if you want to add the same meta-tag on all pages
You could maybe pull off similar result by adding a component to the sidebar. It won't cover all cases (like accessing Reports/Dashboards) but it's hard to say more without knowing what you're really after. Then again - custom VF page overrides won't help you when it comes to Reports either.

I wanted to add this as a comment, but was unable to.
Anyways, For the example that you mentioned in the comment, You can add that jQuery plugin in the Home page side bar component and activate the plugin only on those custom objects where you wnat to run this plugin. You might already know that we can deduce which object a record belongs to by looking at the 1st 3 letter of the record Id, using this logic, check if the record belongs to the custom object you want your plugin to act on and run the plugin.
But As eyescream has pointed out adding script in side bar has its own limitations: you cannot use the global variables , side bar components are not loaded on the reports and dashboard tabs etc.
-ಸಮಿರ್

Related

Salesforce modify standard forms for lead generation

I would like to change the standard form for creating a lead a bit. Actually i just want to add a link to another form to allow the user to quickly jump to it (our appexchange app). I thought i could use visualforce page and override the "normal" lead creation mask. But I believe this won't work since i probably need to implement an exact copy of the normal form source code with the link additionally and also need to wire it correctly to the actions.
Since i can't find the source for the "new lead" page, it seems quite hard to do it that way. Is there any other way to add a link to a stanadard/existing form in SF ?
Any hints?
You should be able to cheat. Create a VF page with 2 links, 1 to your form, 1 to normal "new Lead" page. Read up about {!URLFOR} and the optional "no override" param (that just adds &nooverride=1 to the url), should take users to normal form.
Failing that you might be able to use lightning:recordForm (pick Aura or LWC) to magically reuse the page layout crafted by admin. You'd marry that to your VF page using Lightning Out - or just make your override completely an aura/lwc? It's marked as beta so I don't think you'll be able to package this as your appexchange app... Maybe provide the component and instructions for admins how they can copy paste your code to their own VF page and bypass the packaging woes.
If you really want - you should be able to recreate standard Lead layout in your VF using Layout class too. Sounds ugly but well, last resort before completely forgetting about the standard layouts, teaching admins about fieldsets and stuff?
Are you sure this is the right way to attack the requirement? Override (especially via VF) will be slower and if you ever create leads from related list (say Campaign -> members -> new -> add inside lookup?) you lose some flexibility. I'd make 2nd "New" list button and drop it in Lead tab or maybe add component to bottom utility bar?

Find where and how objects are used in Salesforce.com

I have recently taken up salesforce.com and i have very little idea about its workings and stuff. Recently i was going through some of the stuff and i had a doubt...
Is there any way through which i can find out where an particular field/ object/ visualforce page has been used in an application. For example lets say i have a field labeled Sales, i want to be able to find where that particular field is used, under which object, and the object in which visualforce page/ Apex class, and the visualforce page/ Apex class is used in which application.
Hope i have made my Q clear.
Thanking everyone for their help
It's not really a programming question, you might be better off asking about administrative stuff like that on salesforce.stackexchange.com.
If you have a test environment (sandbox) - you could always try deleting the field there ;) I'm kidding but if you'll try it the page should display you a list where the field is being used.
Similar thing could be achieved by creating a changeset, adding that field to it and then checking dependencies.
But probably the best way would require some preparations upfront. Read about Force.com IDE (or Eclipse IDE) and how to use it to download files that represent your object definitions, page layouts, classes, visualforce pages, reports... This is great as backup but also will let you search the files (Ctrl+H in Eclipse or just use whatever you want once you have the files locally). Search for API name of the field (similar to My_Custom_Field__c should be most effective.
Pretty old thread but adding another option. I have a free and open source app that scans the fields in your Org and returns the components it's used in (Workflows, Processes, Page Layouts, Apex etc).
Keep in mind that returning fields in Apex and VF is not 100% accurate, as a field with the same API name on different objects would return as being found in a class, even though it might not (as others have mentioned).
Also, it can take quite a while to run on large Orgs.
App: http://schemalister.herokuapp.com/
Source Code: https://github.com/benedwards44/schemalister

How would I repeat content on pages (and modify some) in DNN

I am trying to figure out how to place content across pages as well as modify only some of the "same" things.
For example, I have two services. Let's say I want to add a small box on the right panel. On the pages directly under the root of my site (Home, About Us, Contact Us), I want this box to contain generic information (We provide services for . . . ). On the pages related to service one (the service one page and sub-pages), I want that same box to contain pretty much the same text except changing it specific to service one (Our service one solution...). The same for service two and it's sub-pages (Our service two solution...).
To change content I think I'd be right to leave "Make a Copy" checked. However, I don't want this box to appear on every page, just one's that I choose (whether grouped or not; i.e. root pages, service one pages, service two pages).
How can I accomplish this? I'm working directly using the DNN 7.01 admin/host interface - I'm imagining I can accomplish this by creating separate .ascx files, but for this I think it defeats the purpose.
Thanks.
What you will want to do is use the "Add Existing Module" function to handle this.
For example for the content that you want to be the same, add it to the "main" page and setup the content. Then on the pages that need to have THAT version use "Add Existing Module" and add the module from the "main" page.
Then, when you have a variation that is to be shared across other pages, repeat this process.
DO NOT use the "Display On All Pages" option though as more than likely that will trash things!
I've not a lot of experience as Mitchel, and his answer seems the way to go. But as an alternative (when dealing with LOTS of modules with static content), I found using a template page with all the modules (and content within) helps to group things so that you can use that template for sub pages that have the same content. In other words, only the actual content pane for a sub page needs to be created because you are copying all the other "widgets" you have on your page.

Adding DNN module error when control has key assigned

I'm creating a module and I was able to add a user control as a view type and everything worked. I want to add a second control, also as a view type, but that's where trouble begins.
If I just add the new control to the module definition, it displays only that control and not both. If I remove it, the original control displays fine. Going back into the module definitions, I went to the module controls and assigned values to the respective Key properties. When I save, my module disappears from the page it was displayed on. If I try to add it again, I get "Object reference not set to an instance of an object."
It was through trial and error I discovered if I remove the key, I can re-add the module it works again (at least as described above).
Essentially I want multiple views for my module where individual views can be displayed on different pages (much like the Blog module). I'm not creating a package for distribution so I'm almost to the point of just creating a separate module, but where's the learning experience in that?
I've searched for a tutorial on creating a module with multiple views with no luck. Can anyone provide some insight?
I got round this issue by using the modulesettings to choose which display I wanted for that instance, in my case I used the setting to determine which front end was visable and which was not aswell as the backend code.
Another option is to have one view ascx which is a placeholder and inject either ascx view you want based on a modulesetting.
I have used both these methods before and both work well
In DotNetNuke there can only be one 'View' so if you want to make something that displays different views depending on the situation you have to create a Dispatch view. So depending on your module setting like you have, or a URL parameter, cookie, session, something in the primary View gets another user control to display what is needed.
This post talks about it a bit Dispatch View
Sounds like you found a solution that works for you.
Out of the box DotNeNuke also supports using multiple views, however as soon as you switch to a different view the module enters "Isolation Mode", where it becomes the only module visible on the page.
If this behavior would work for you, then you can add multiple controls, the FIRST control you add without a key, the secondary controls you add with a specific key. You can then use NavigateUrl or EditUrl to construct the link to the specific controls.
From an "edit" perspective, the use of this pattern ensures that your users have a consistent environment with only your module. From a View perspective the usage of other patterns is more commonly a "better" choice.

Is there another way to do screen scraping apart from regular expressions?

I'm doing a personal, just for fun, project that is using screen scraping to give me a System Tray notification in case another line on an HTML table is added, modified or deleted.
Having done this before I thought: well let's go with the regular expression thing and that's it, but being a curious person, made me think that there could be something else out there that could have another paradigm but be as simple to use.
I know about DOM and X-Path and all the xml'ish approaches. I'm looking for something outside the box, something that can even be defined in a set of rules so you can make a plugin system to aggregate various sites.
See Options for HTML Scraping
Here's an idea: assuming your main use case is getting a notification whenever an HTML file changes, why not use a standard diff tool and then loop through the changed lines, applying your rules?
Also, if this is a situation where you have access to the server and the files you're watching, you might be able to put everything under source control with CVS (or similar) and just watch for commits. If you want to use this approach for random sites on the web, just write a script that periodically downloads the html for the appropriate URLs and then commits it to source control and watch the diffs.
Not very practical, but outside the box.
If you can convert the source into valid XHTML/XML using something like SgmlReader or HtmlTidy then you could use XSLT. Simply create a XSL template for each site you wish to scrape.

Resources