Override a button using lightning component in Salesforce - javascript

What I'm trying to do is to recreate the "New" button in custom object's list views. The only difference between the existing standard "New" and the one I'm trying to create is that so I could control which recordtypes to show and which to hide. The 17 record types that I need to hide are being used to create records ONLY by using a flow. I have tried creating it myself and searching for similar codes but no luck.

I would suggest please use the out of box salesforce profile settings to control record type assignments.
For instance, lete say you have 3 record types A,B,C.
A,B should be visible to Profile 1
C should be visible to Profile 2
You can go to profile settings and Assign relavant record types for each profiles.

Related

Sharepoint Framework Property Pane - building a dynamic property

I'm attempting to build a dynamic property in the Property Pane of a React based Sharepoint Online Web Part.
In order to achieve this I wish to iterate through an array of data in the PP, to create multiple drop down fields. Currently I can only create drop down fields through individual variables, not arrays or objects (as these can not be iterated through in the PP render method). This means that I can only render a predefined number of drop down fields in the PP.
Microsoft have already achieved this functionality on their 'Highlighted Content' Web Part, but haven't published the source code for this, so I cannot see how they have achieved it. On this Web Part the user can add multiple PP drop down fields and remove these individually too, without limit (i.e. they are rendered fully dynamically).
Is this possible to do or am I taking the wrong approach?
[![MS Highlighted Content Web Part][1]][1]

which is better to perform logical operations in angularjs controller or view?

My website contains posts something like blog posts, a registered user can post things and any other registered user can view them, here when showing individual post I kept an follow button for to the viewer so if the viewer clicked it and follow the author(post owner). Now the problem is every time when a viewer clicked and see individual post I need to check whether viewer is already following that author or not so that I have to choose follow or following button to display. In my angularjs controller I have json array of authors(following authors). How can i check the individual post author existing in following authors in controller or is there any chance to perform this on view? O am using angularjs 1.x
Anyway you have to set a flag for the buttons choice (true for follow button and false for following button).
To set the scope of this variable you need to implement the logic in JS (Since its an array collection). Now in HTML you can show the follow or following button by using ng-show and ng-hide. (ng-show="isFollow")

Different view levels according to user's role

in my application, I would like to achieve multi access level for different users depending on their role. I am developing application in openUI5. When I log in to the application I know what roles user have. And according to that roles, I would like to display or hide certain links, tiles, gui components.
Multi access level I mean
displaying/hiding gui elements
disallowing routing to specified places in application
The point number 2. I have achieved. That's no problem - according to role, I add specific routes to allowed routes.
I would appreciate an advice for point number 1. what would be the best practice?
Thank you
Depending on the user's role (a set of authorization rules), you can control the UI in a following ways:
Huge differences in UI
If the UI should be VERY different depending on user role, it makes sense to implement different set of views created for each role or even apps.
A few "change points"
In case of not really much differences, you can set up the configurational JSON model, which will contain visibility rules for a certain UI element and you will bind the "visible" property to this configurational model. A set of rules can even be fetched from backend, so it won't be a hardcode on UI, which is pretty handly for customizing reasons.
User authorization + object state handling
It is also might be the case (very often in my projects), that not only user role has influence on the state of the UI, but the object's state or business logic should define how the UI should look like. I'm talkin about the things like:
should the filed be displayed or hidden; read-only or editable mode allowed;
should the action buttons be hidden/visible/clickable and so on;
should the any UI part be hidden/displayed.
In this case it's easier to let backend control over that by using so-called "field controls". They are simple properties in your OData entity type(s) (where needed), which hold the rules for UI.
For example in your entity type you have the field "Amount" and in some cases it should be read-only, while in some others - editable. So you need to add a field-control "UxFc_Amount", it should be integer type and contain 0, 1 or 2:
0 - means field should be fully hidden
1 - means field should be read-only
2 - means field should be editable
Then you bind appropriate properties of control, i.e. for Input control: "editable", "visible", "enabled".
For buttons you can introduce "action controls". Let's say you have a "header" object which is bound to the whole page and depending on user's role and the internal object state/status the "Submit" button should be available. So you introduce "UxAc_Submit" property which is a "boolean" (Edm.Boolean) and bind the "visible" property of the button to this variable, if it's false - the button will be hidden.
The same approach can be used for showing/hiding the whole sections on UI (for example when you use ObjectPageLayout control).

Parent file create child file (need some help on logic)

Question :
Let say i have an application form that allow me to apply for few service.
for example services are :
Service A
Service B
Service C
Condition :
one application form only allow one user to add few service
Parent file is "application form"
Child file is "service 1", service 2, Service 3
user have 2 button to select either to click on "save" / "Cancel" at Application form(parent file)
My form allow to be save anytime.
My question, if user already add the child document, but user click on "cancel" function. Means it want to delete document(child) that been select on the time key in. How to differentiate it.
A few approaches come to mind.
The first is to only allow creration of child documents in read mode. That splits the separation between creating the parents and the children.
The second is to have child documents get a "Draft" flag when initially created. If they save, clear the draft flag. If they cancel, remove drafts.
The third is similar. Capture which children exist when they first edit the document, then in the cancel process, remove them.
Steps 2 and 3 still have the problem that edits to an existing child will still be held. A fourth option is to load the children into Java objects that wrap the underlying Notes document. Creation will create the Java object, not the Notes Document. Save will then create or update the backend Notes documents. This way you're able to handle parent and child as a single transaction and this will be the most complete option. (DominoDocument datasource is effectively a Java class that's a wrapper of the backend Notes Document, so it's effectively the same thing, but covering multiple documents instead of one).

Ng-admin custom reference list - with ability to create new entry

I'm trying to figure out how I can make a custom directive which will combine:
reference list select field
create button which will show a reference entity creation view
and on creation save. reload reference list entities, so i can choose a newly created entity.
It can be easily done using completely custom code, but i want to make it using ng-admin templates and directives.
It's also quite common functionality, but i'm having a hard time integrating it into ng-admin.
So in case there is no required field in list, i will not loose data i already entered by navigating to create new entity on another page.
Add two fields:
one of type referenced_list to display related entries
one virtual field with an empty label and a custom template, using a create button with prefilled default values for the related entry (e.g. <ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>)
Check https://github.com/marmelab/ng-admin-demo/blob/3a0944acbcb12dc20dc8a4a860c6c9f8da9c1645/js/customers/config.js#L81-L101 for an example.

Categories

Resources