How to call Data Editor from Code, C1 CMS? - c1-cms

Under definition tree, I can attach event to open Data Editor for certain element.
However, I have no idea how to trigger the workflow to open the Editor for a given id.
I have a custom action URL which point to a custom ASPX (List of businesses about 50,000) in the console.
Now I want to trigger call the default data editor from the custom ASPX. Is that possible.

Yes you can. There is a few steps you need to take, but then you can basically mimic all console behaviors from your own aspx-page.
First of all you need to include the necessary C1 Console javascript frameworks on your page. Do that by calling ScriptLoader.Render("sub") and write the result on your page. You would also need to include this javascript on your page https://github.com/burningice2866/CompositeC1Contrib/blob/master/Teasers/Package/content/Composite/InstalledPackages/CompositeC1Contrib.Teasers/teaserConsoleFunctions.js - its some wrapper methods which are able to construct the javascript objects needed to call C1's webservice methods.
When that is setup you can trigger opening a Edit Workflow by calling the executeAction javascript method via a link containing the necessary ActionToken and EntityToken like this https://github.com/burningice2866/CompositeC1Contrib/blob/master/Teasers/Web/UI/TeaserHtmlHelper.cs#L65.
Its important to understand that everything in the C1 Console in based on these tokens. You don't edit something based on its id but always based on the EntityToken the something is represented by.
And what you want to do, whether its edit something or delete it, that thing you want to do is represented by an ActionToken. So to be able to edit something, you need an EntityToken for that something and a ActionToken for the Data Editor.

Related

Accessing CustomFieldDefinition metadata via tooling api

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?

How to process and change output before it is sent back to the browser?

I want to implement a mechanism in CakePHP that is like ShortCodes in Wordpress. I want to save my pages (in the DB) with tokens, e.g.
[form id=12]
and then, after the view got rendered and before it is sent back to the browser, I want to search the rendered view for these tokens, and replace them with something else.
I assume I'll have to use beforeFilter, afterFilter or beforeRender, but I can't find any documentation (including in CakePHP's own documentation!) about how these overriden functions can be used to change the output.
Can anyone help?

How to copy document file from one site to another

I am looking for an example where based on the title name with in the object model I want to copy a single file from one Document library to another. I have more than 2000 files and don't want to loop through to complete collection is there any simple way to accomplish this.
There is no method like GetDocumentByName to use. But when do you want to do this? If you want it triggered by a user, you can use a custom action on the document library and when it's triggered you know what item triggered it.
If you want it done by a job I guess you could create a hidden SPView on the library that filters on the title. I'm not sure it's a great solution, but it can be done at least.

Want to display results of a callout

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.

Where do I add a trigger for "Notes and Attachments" in salesforce.com?

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.

Resources