function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
soasoa 

How to accomplish the following scenario through UI

Hi,

 

I have a use case which has 3 tables namely Transaction Table, Customer Table and Merchant table.

 

Based on the no of transactions of a particular Customer in the transaction Table i need to insert the total no of transaction of that Customer in the Customer table.

This i could accomplish through Before Insert Trigger.How can I do this through UI.??

ie through a button.

 

Pleas reply as soon as possible.

 

Regards

Diti

 

aalbertaalbert
Are you asking how to initiate the trigger? When a new transaction is inserted, through the API or UI, your trigger will fire and then insert the proper dta into the Customer table. So in short, the action of hitting "Save" in the UI to create a new record will fire your trigger.
SteveBowerSteveBower

 I think you're asking "I have some functionality that works as a Trigger, but I also want to invoke it manually through a button".

 

Break out your code so that the bulk of the processing is in a stand-alone class.

 

Then write your trigger to invoke a method on that class, passing in Trigger.new, Trigger.old, etc.

 

Then, write a VisualForce page that has an apex:page onload function specified. In the controller for the page your onload function invokes the stand-alone class as well.  Then the VF page can return the user to where they were.

 

This way you have the same Apex functionality being invoked through a trigger, and through a button.  (Of course you need to make sure the parameters you pass are going to work either by munging them into the same format and using only one invoking method, or having multiple signatures in the standalone class.)

 

Hope that helps, Steve.

 

soasoa

Hi,

 

Thanks for your prompt response.

 

As mentioned by Steve Bower - I have some functionality that works as a Trigger, but I also want to invoke it manually through a button.

 

As mentioned in the solution suggested by you, one option is to use visual force.

 

But is it possible to do it through app-builder.. as I have implemented my current application using appbuilder.

 

I am calling a fnction from the button click from Appbuilder form

The function takes some parameter ( say customer Name) for a selected customer record.

Is it possible to pass this value to the fucntion.

 

As given in the example (Salesforce platform Cookbook , page no133)

 

var jobAppIdArr = {!GETRECORDIDS( $ObjectType.Job_Application__c )};

 

var jobApp = new sforce.SObject("Job_Application__c");

 

Is there a way that in a similar manner i can take any of the fields from my object to do the processing?

 

Please reply me as soon as possible.

i am stuck.

 

 

Regards

Diti