Salesforce - Hiding visualforce form items based on organization - salesforce

I have a custom viusalforce page as part of a package that i'm developing. The package will be installed on a number of different Salesforce organizations. I require to hide certain parts of the visualforce page (input boxes) based on the organization using the package. What is the best way to accomplish this? I can hardcode it based on Organization ID but I'm not convinced this is the best way, as when clients refresh sandboxes the ID will change.

You should use rendered attribute on apex:input evaluating the org criterial:
<apex:input ... rendered="{!facility.Facility_Address_2__c!=''||render}" ...>
Where facility.Facility_Address_2__c could be the inline evaluation criteria of some org object.field value or render could be a flag set on controller evaluating a deeper criteria.

Related

update availableOptions for multiselect Picklist through Apex trigger

I have created a multiselect picklist which shows the list of users on a custom object. I want to update the available values on this picklist through trigger on User object whenever there is a new user created. I do not want to update the Chosen value. Also this is a field on a lightning page, not a vf or lwc or aura component. Is it a possible requirement? Please let me know if any further information required.
Field on Lightning page
enter image description here
Dynamically updating your org's schema based on data changes is both generally a bad idea and much more difficult than it sounds.
Your trigger would have to use Asynchronous Apex, such as a Queueable class, to call the Metadata API or Tooling API to update the picklist values. To do so, it must be authenticated as an administrator, so you'd also need to set up a Named Credential and authorize it as an administrator. And then you'd have to write the moderately complex code to actually create picklist entries based on Users, decide what to do when existing Users/picklist entries are deactivated, and so on.
It is generally a better pattern to implement a custom UI component (like a Lightning Web Component) where you need to present a dynamic picklist-style interface that's driven by data.

Using abp-page-toolbar and abp-extensible-table

I am trying to use both components in my angular application. I am a backend developper and absolutely newbie in angular. I have been reading the roles and users components in the source code and I think I cloned it for my Customers component. I have guards, defaults and all the code like Roles and Users but, although the code compiles and the API call is done, I have nothing in the screen, only the Total records are displayed. No action buttons, no table rows, no pagination...
Is there anyone who has use these components and can bring me some help?
Many thanks
Those components are needed for customizing built-in modules. Let's talk about Users for example. The Users component is a built-in page and you do not have access to its code. However, you may still need to make some changes like adding a New User button on the toolbar or changing its columns, form fields etc. That's why ABP Framework provides some injection tokens to override/extend/customize these features. Since you are developing your own page, you do not need any of this. You can directly use ngx-datatable in your own component, add or remove columns and so on.

How to find the code behind in Apex

I'm new to Salesforce / Apex
There is this guy worked on our salesforce and he left me with many code. My questions, we have a little problem with some of the fields on one of the application form. How do I find where is the code behind this application? Thanks.
There are a few ways in which Apex can be added to perform custom logic in your salesforce application, there's no clear answer which is doing what and you'll need to dig in to discover that if nothing has been documented in your organization.
Check if any triggers exist
Verify if any apex jobs are scheduled, they can be performing apex batches executign logic
verify if your application page are default page layouts or whether they have inline Visualforce elements or are a full Visualforce page. Anything Visualforce is most likely backed up by apex controllers performing business logic.
Beyond Apex, have you checked if there are any configured workflows which are performing field updates ? These too can modify data.

in backbone.js can a Model be without any url?

I have an app where the menu system is built dynamically using metadata fetched at startup. Based on this data, and menu selections, I need to craft a "filter box" where user can input search criteria. The "main" View consists of a filter box plus a search results panel where result(s) are rendered in accordance with their classes.
Can I model the Filter Box as a Backbone.js Model? It does not have any data fetches from the backend as its composition depends entirely on the menu selections + the metadata? E.g. when user selects "Sales" menu then the filter box might prompt for "Sales Order Number" whereas when user selects "Material" then the filter box might prompt for something else.
I would then use this widget as component of the "main" View, along with a set of results views made up on the fly. As users make their menu selections, this main View will un-render the existing filter box and recompute and re-render a new one. Other components on the screen could query the Filter Box for its settings.
The examples I have seen so far always have a url and a server fetch, save, etc. The only url-free example on the tutorial page says it is a "contrived" example. I was wondering if a backend provider is necessary and programming will be full of gotchas without conforming to this requirement.
Thanks.
You can have models without url property defined. One of the building blocks of Backbone is the Sync object, that will help you when pulling and pushing data, ideally from/to REST endpoints. For this to work you need to tell where the data are served, and to do so you set a value to url on Models or Collections.
If you don't need server comunication but you just want to use the utilities provided by simple Model or Collection (such as event handling, filtering, etc..) you just don't set url and you are good to go (just keep in mind that methods like fetch or save won't work).
Yes you can use Backbone for your DOM logic too. A model doesn't need to represent data from the server. Do whatever you like with the few basic elements of Backbone, simply use them when you feel like it'd do a great job :)

Prepopulate fields in Salesforce.com

I have a doubt, i've been working with salesforce for a while and now i have a requirement from a customer.
They need that some custom fields be populated with a value of parent object, making some research on stackoverflow, i found this post, but this isn't working for me because my project is a manage package and when this is installed on a another salesforce instance the id of custom field change.
if someone could help me, I will be grateful.
Thanks!.
I can't see any way of doing the same as that post without using the IDs, I was thinking you could route via a VF page and build up the URL in the controller but it doesn't seem as though you can get the IDs of fields, just their type etc..
I think the best you could do in this instance is to override the default new recordpage with a visualforce page. In the constructor of your controller you could then loop through the page parameters and pre-fill the corresponding fields on the new record before it's displayed on screen. Using fieldsets or just an <apex:Detail> component would keep the level of effort down and also maximise the flexibility of the page for the end users.

Resources