hi i use sonatadminbundle to manage my entities i works very good. but i want to customise message when adding deleting updating my entity by default it look like this AppBundle\Entity\Product:000000000727a2de000000005cccd6bd
Item "AppBundle\Entity\Product:000000004284b7de00000000791d9693" has been successfully updated.
i want to add my own message
thisis my dashboard
The success message is a standard symfony Flash message.
The messages are set in Sonata\AdminBundle\Controller\CRUDController with keys : sonata_flash_success / sonata_flash_error / sonata_flash_info and associated with a generic translation.
You can override the translations, or if you want you can override the appropriate action in the admin controller and do what you want.
You can also start by adding a _toString() function to your entity which is much better than "AppBundle\Entity\Product:000000000727a2de000000005cccd6bd"
Related
So, I've been attempting to gather picklist dependencies per Opportunity record type for my lightning components. I have been able to retrieve Standard Field dependencies by RecordType, but it the Tooling API will not return the custom field dependencies. Standard calls and queries will not work either, as they state that the field has no controlling value or dependency.
Given this information I suspected that there was a table that is hidden somewhere that contains the keys for the RecordType and FieldDefinition, hopefully with a nested Metadata object.
I found an Id in one of the parameters in the setup menu for a Record Type and Id.getSObjectType() on it. The table name is CustomFieldDefinition. However, it is not accessible via SOQL or the Tooling API.
Has anyone accessed this table? Or has anyone been able to retrieve the field-record type picklist dependencies on custom fields AND standard fields?Tooling API ResponseDebug Log with SObject Name
I think you're doing it wrong.
"Controlling field" would be another picklist or a checkbox for example, something you change during same edit action. If you have dependency to record type - in that sense it's not a controlling field. Sure, you change record type and picklist changes - but really everything would change, it should be a different page layout (different fields shown, marked readonly/required etc). There's a reason that record type change is not done on normal edit screen, you do it by clicking special link on detail view and then everything "explodes".
Have a look at "User Interface API" - set of tools meant to help your custom app (mobile? desktop?) steal recreate a normal page layout. This one might be especially useful: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_picklist_values_collection.htm
There's even a Trailhead: https://trailhead.salesforce.com/en/content/learn/modules/user-interface-api (skim through whole set but especially read last module)
And since you mentioned Lightning Components - are you aware of these ready tools:
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_ui_api
getPicklistValuesByRecordType
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_generate_record_input_create
or maybe you don't have to code it all and stuff like <lightning-record-edit-form> with recordtypeid passed to it will solve all your problems
Have a look, if I didn't give you a working solution then at least you have some keywords to Google around. If you're still stuck - try to post a code sample as new question?
I'm using sonata admin in my project I have two entities, Order and Delivery which are related in a oneToMany relationship. Each of these has a oneToMany relationship with OrderItem and DeliveryItem respectively.
I would like to make it easier when creating a Delivery by loading corresponding Order Items by pre-populating the items delivered through an ajax call based on Order item selected.
I extended the edit theme and can make the ajax call which populates fine, however when trying to save, I get the error in relation to my form having extra fields even though I've followed sonata admin's naming convention to the letter.
Is there a way to do this?
when calling formMapper->add() you can pass the 'allow_extra_fields' => true option.
http://symfony.com/doc/current/reference/forms/types/form.html#allow-extra-fields
When a user 'Saves' a Contact (for example), whether it's new or just updated, I need to:
Do an external callout using one of the Contact field values as a lookup
Display the results of the callout, so the user can make a selection
Update the Contact based on the user's selection display the updated Contact
I have found two aproaches, but have reached a point in both that I need to resolve.
Trigger Based Method
In the 'after' trigger pass the lookup string to a callback.
Update the Contact with the selection
Issues
How do you pass the lookup string or results to a visualforce page to display the lookup results?
When the user makes the selection and the update has been done, how do I move back to the updated contact?
Override Base Method
I found a discussion here that seems to suggests using overriding & redirection to someone asking about 'Edit'. I think this could also be done with the 'Save' button.
Issue
This is meant to be a deployable sollution, so I think that the override has to be set in code (I'm using the IDE) and not via Setup (or am I wrong?). I can't find out if this is possible or how to do it
Sorry for detailed question. Didn't want to just ask the wrong question (i.e. assume I know the best approach).
Thanks...
For the trigger-based method, you cannot change the built-in Save functionality, but (per your second solution) you can override the Edit button and recreate the Edit page with Visualforce, which would give you full control over the Save button and how you handle the callout and redirecting.
The release notes for Spring '10 indicate that standard-button overrides are now available for packaging, as they can be created through the Metadata API.
I'm writing triggers / classes to post field change notifications to the Chatter feeds of objects related to the object undergoing change (e.g. posting a field update of an Opportunity to its related Account is changed).
I've written the code to compare the before and after values and post feed updates for the values that have changed just fine. But I only want to post updates for fields that are set to be "tracked" in Chatter (Setup -> Customize -> Chatter -> Feed Tracking).
How can I get at these settings in Apex?
(It's possible to call isFeedEnabled() on an object to see if Chatter is enabled for that object. But I don't see any way to tell if an individual field is set to have its updates posted to the feed)
Cheers,
Ray
There's call like isFeedEnabled() for checking on field-level tracking (both for chatter and the old style field history) sadly.
You could however use a trigger on the feedItem sObject to see if an item where Type == 'FeedTrackedChange' is created, and if so query the FeedTrackedChanges related to that FeedItem; then create the chatter post from there.
I cannot find where in the salesforce.com UI I can add a trigger on a file attachment. I can find triggers on almost everything else, but attachment seems to be missing from the list (even when I view source on the page and search it. Does anyone know WHERE I can put this trigger in?
There is no way to do it directly as Attachment is one of those "lesser" objects that salesforce really gets "protective" about in a random and biased way. The only "legit" way to do it is to use some external build&deploy tools such as Force.com IDE.
If however you are not a stranger to undocumented 'hacks' do the following. Go to any object's trigger list and click create new. In the URL locate entity query string parameter (e.g. entity=Case) and change it to Attachment (entity=Attachment) and press Enter. Newl loaded screen will accept Attachment trigger.
Using Eclipse (Force.com IDE plug-in), right-click on your project & select "New" > "Apex Trigger". In the dialogue window that pops up, there is an "Object" dropdown / picklist, choose the object you want from this list - "Note" or "Attachment" etc. - then choose the "events" you want to trigger to execute on.
NOTE: a best practice is only one (1) trigger per object since you cannot guarantee the order in which multiple triggers on the same object will execute.
Have you tried creating the trigger from, force.com IDE??
In my opinion it should be possible from there.
To write a trigger for attachment, there is no straight way to do it but you can do it.
By creating a trigger on other object for example create a trigger in contact object then the url of the current page shows
"https://ap1.salesforce.com/........./&entity=Contact" you have to change "entity=Attachment"
then the trigger will be created for attachment object.