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
sumpritsumprit 

cross object workflow (from the Product/Asset object to the Account object)

Hi there,

Has anyone created a S-control that would display the cross object workflow between objects? Is there an example I can refer to?

Or can u give where should I start from, I am really struggling with this one.

thanks
RickyGRickyG
Suma -

I am not sure what you mean by cross-object workflow.  Do you mean having a workflow update a field in a different object?  You cannot do that at this time.

Hope this helps.
sumpritsumprit
Hi Rick,

Here is my requirement. Maybe you can point me in a right direction:-

1.> On Accounts object, I have "Add on" called "Assets". There is also a NEW button on this page. So, from the Account button when you click on NEW button to create a new ASSET for that specific account. IT opens up another page.

2.> There is a Lookup field called "Product", from where the user selects the product name. When you save it, that Asset is saved for that particular Account only.

3.> SImple!

Now, here is what I want to do:-

I want that when user selects the product/Asset name from the ASSETS object and he saves the data.



a) The “checkbox” in the product list should be checked automatically. So if the user selected “Karpower” from the product list, the same should be checked in the Account object product list.

That means I have 2 objects Accounts and Assets. I am trying to update the custom fields of the Account object (20 fields or more) based on the product name that the user selects from the Assets object.


What is the best approach to get this done?



sumpritsumprit
Rick,

Based on this requirement, I was able to create a Trigger on Account, that is getting the product name from the Assets and based on the product name, it is checking the custom field on Accounts tab.

Notice, at the end, I have come up with 2 options, to match the product name from Assets to the custom field on the Account.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

trigger Checkfields on Account (before insert, before update) {

//First need to determine the distinct Asset/Product Name that user entered for each account

    Set<Id> prodname = new Set <Id>();
    for (Accounts acts : Trigger.new)
    {
        prodname.add(acts.KARPOWER__c); // the Asset productname is matched with the first custom field checkbox
                        // we will need to add more fields here, after this is sucessful.
    }


// Next query the ASSETS object to get the ProductName Entry

Map<ID,prodname>entries = new Map<ID,prodname>([SELECT Product,ProductCode from ASSETS WHERE Product IN:prodname]);

===================================================================================
// Now, checkmark the fields in ACCOUNTs based on the user selection from ASSETS
// 1st OPTION

for (Accounts acts : Trigger.new){
   acts.KARPOWER__c = entries.get(acts.prodname) Assets.Product;
}
   


===================================================================================

// Now, checkmark the fields in ACCOUNTs based on the user selection from ASSETS
// In order to implement this logic, we first need to define ASSET somewhere which is equal to ast. Where would that be?
// 2ND OPTION

for (Accounts acts : Trigger.new){
   
            if (ast.Product == 'KarPower'){
                  a.KARPOWER__c = True; }
               if (a.ProductName__c == 'Books'){
                   a.Books__c = True; }
             if (a.ProductName__c == 'PriceLink'){
                 a.Pricelink__c = True; }
             if (a.ProductName__c == 'Product KarPower'){
                 a.Pocket_KarPower__c = True; }
                

        }

}