• Vladimir Satura
  • NEWBIE
  • 130 Points
  • Member since 2016

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 22
    Replies
I have trigger which is working but I need to update it and it is giving me an error ( only bold one is newly added)

I had two fields and based on the combination it was working but now I need to add another checbox called Active__c and if current condition and if Active__c is true then only trigger the trigger. It is giving me "Variable does not exist" error on Line 28

trigger Triggerupdatedirectbill on FX5__Ticket_Item__c (before insert, before update ) {
    if(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate) ) {
        List<FX5__Ticket_Item__c> items = Trigger.new;
        Set<String> accountsIds = new Set<String>();
        Set<String> wellsIds = new Set<String>();
        for(FX5__Ticket_Item__c item:items) {
            if(item.Customerforlogiconly__c!= null) {
               accountsIds.add(item.Customerforlogiconly__c);
               System.debug(accountsIds);
            }
            if(item.Disposal_Location_on_Ticket_item__c!= null) {
                wellsIds.add(item.Disposal_Location_on_Ticket_item__c);
                 System.debug(wellsIds);
            }
        }
        Map<String, Obj_Direct_Bill_Customer__c> directInvoicesMap = new Map<String, Obj_Direct_Bill_Customer__c>();
        for(Obj_Direct_Bill_Customer__c di :[Select Direct_Bill_Customer__c, Disposal_Location__c, Active__c from Obj_Direct_Bill_Customer__c where Direct_Bill_Customer__c in :accountsIds and Disposal_Location__c in :wellsIds] ) {
            if(!directInvoicesMap.containsKey(di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c) ) {
                directInvoicesMap.put(di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c,di);
            }
            System.debug (di.direct_Bill_Customer__c);
            System.debug (di.Disposal_Location__c);
            System.debug (di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c);          
        }
        for(FX5__Ticket_Item__c item:items)       
         {
         System.debug (item.Customerforlogiconly__c+'_'+item.Disposal_Location_on_Ticket_item__c);
           if(directInvoicesMap.containsKey(item.Customerforlogiconly__c+'_'+item.Disposal_Location_on_Ticket_item__c) && di.Active__c==true){
                item.Direct_Bill_Customer__c = True;
                  }
            else {
                item.Direct_Bill_Customer__c = False;
            }
                
        }
        
    }
}
 
Hi I am new to salesforce trying to write a trigger. I need to update a field in custom object when ever a field Y changes from blank to some value  in contract object the value should be saved to the custom object field X.

Thanks in adavance

I wrote the following
trigger Caseidcustom on Case (after update, after insert) {
    list<Custom object>  i =  new list<Custom object> ();
    
    for(Case cs :trigger.new)
    {
        Case oldCase = trigger.oldMap.get(cs.X);
        
        if(trigger.isInsert) {
            Custom object o = new Custom object ();
            o.Y = cs.X;
            
        }
        
        if(trigger.isUpdate && oldCase != null ) {
            Custom object o = new Custom object ();
            o.Y = cs.X;  
        }
        
    }
}

getting Review all error messages below to correct your data.
Apex trigger Caseidcustom caused an unexpected exception, contact your administrator: Caseidcustom: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: ()
I have two buttons on a Lightning Web Component on a record page. When each is clicked, the code they run is virtually identical, so I want to reuse the code as much as possible. However, I cannot figure out the best way to do it. I can pass the button name into the code, but when I try to put the "let record + fields" code into the switch or conditional if statements, it doesnt work. I need to pass a different field name into the 'let record' statement, depending on which button is pressed. 
 
handleActivateBuyerSide() {
        this.loading = true;
        
        let record = {
            fields: {
                Id: this.recordId,
                VirtualTCStatus_BuyerSide__c: 'Active',        
            },
        };
        updateRecord(record)
            // eslint-disable-next-line no-unused-vars
            .then(() => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Record Is Updated',
                        variant: 'success',
                    }),
                );
                this.loading = false;

            })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error on data save',
                        message: error.message.body,
                        variant: 'error',
                    }),
                );
                this.loading = false;

            });
    }
    handleActivateSellerSide() {
        this.loading = true;
        
        let record = {
            fields: {
                Id: this.recordId,
                VirtualTCStatus_SellerSide__c: 'Active',        
            },
        };
        updateRecord(record)
            // eslint-disable-next-line no-unused-vars
            .then(() => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Record Is Updated',
                        variant: 'success',
                    }),
                );
                this.loading = false;

            })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error on data save',
                        message: error.message.body,
                        variant: 'error',
                    }),
                );
                this.loading = false;

            });
    }

 
Hi, I want to start by stating that I am by no means a developer and am not familiar w code....that caveat out of the way, here's my quesiton:

I am fairly new to my org, and there is an integration w a 3rd party whereby they (the 3rd party) will create cases in our org when a document needs review.  When this case is created, there is a link on the case record that will take the user back to the document in the 3rd party system for the user to review.  

Once the issue w the document has been resolved, the user can then go in and close the case, either by clicking the 'Close Case' button, or changing the status to a closed status.  When this happens, there is some sort of trigger that sends a response back to the 3rd party system.  In production this is working fine, but I recently did a sandbox refresh and that 'Case Closed' response, is not being sent.  The inbound part of the integration is working whereby the cases are being created as they should be, and we can update and close, but its that last response that is not working.

I have confirmed the follwoing:
1. the remote site settings have been update to point to the dev/QA environment of the 3rd party (not production)
2. the url that is embedded on the cases when they're created are pointing to their dev/QA environment (not production)
3. There is a case trigger that is supposed to send the response back by calling a 'SendResponse' class and i believe its that part thats failing but no where in the trigger or code can i find specific reference to a url (production or QA).  

What other steps am i missing, keeping in mind Im pretty clueless when it comes to the developer console (i know how to get to it) and code in general.  

Thanks in advance for any sugggestions or thoughts you might have.  
By any chance can we call @future annotated method from visual flow?
I have trigger which is working but I need to update it and it is giving me an error ( only bold one is newly added)

I had two fields and based on the combination it was working but now I need to add another checbox called Active__c and if current condition and if Active__c is true then only trigger the trigger. It is giving me "Variable does not exist" error on Line 28

trigger Triggerupdatedirectbill on FX5__Ticket_Item__c (before insert, before update ) {
    if(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate) ) {
        List<FX5__Ticket_Item__c> items = Trigger.new;
        Set<String> accountsIds = new Set<String>();
        Set<String> wellsIds = new Set<String>();
        for(FX5__Ticket_Item__c item:items) {
            if(item.Customerforlogiconly__c!= null) {
               accountsIds.add(item.Customerforlogiconly__c);
               System.debug(accountsIds);
            }
            if(item.Disposal_Location_on_Ticket_item__c!= null) {
                wellsIds.add(item.Disposal_Location_on_Ticket_item__c);
                 System.debug(wellsIds);
            }
        }
        Map<String, Obj_Direct_Bill_Customer__c> directInvoicesMap = new Map<String, Obj_Direct_Bill_Customer__c>();
        for(Obj_Direct_Bill_Customer__c di :[Select Direct_Bill_Customer__c, Disposal_Location__c, Active__c from Obj_Direct_Bill_Customer__c where Direct_Bill_Customer__c in :accountsIds and Disposal_Location__c in :wellsIds] ) {
            if(!directInvoicesMap.containsKey(di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c) ) {
                directInvoicesMap.put(di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c,di);
            }
            System.debug (di.direct_Bill_Customer__c);
            System.debug (di.Disposal_Location__c);
            System.debug (di.Direct_Bill_Customer__c+'_'+di.Disposal_Location__c);          
        }
        for(FX5__Ticket_Item__c item:items)       
         {
         System.debug (item.Customerforlogiconly__c+'_'+item.Disposal_Location_on_Ticket_item__c);
           if(directInvoicesMap.containsKey(item.Customerforlogiconly__c+'_'+item.Disposal_Location_on_Ticket_item__c) && di.Active__c==true){
                item.Direct_Bill_Customer__c = True;
                  }
            else {
                item.Direct_Bill_Customer__c = False;
            }
                
        }
        
    }
}
 

I am a part time Salesforce admin with no Apex knowledge. I don't even know if this is the right place to post this. Did my research, but couldn't find this information.

Problem is this: We have a native database that has unique identifiers for each of our customers. Whenever we get usage etc. notifications, this identifier is emailed to us. 

For sake of simplicity, let's say this unique identifier is 'google.com' and Google is recorded in Salesforce with a unique ID of "2019" (auto-generated). I created a custom field under Accounts "Native Database ID" and entered 'google.com'.

When I am using Zapier or webform integrations, this 'google.com' is sent to Salesforce. However to, dynamically link activities or Lookup fields, Salesforce requires Salesforce IDs.

So whenever a new submission happens, I want Salesforce to do a lookup on all our Accounts for the field Native Database ID, and when it finds a match, populate that Account.

I know that Zapier has a "Find Account" feature under Salesforce integration, but with our volume, using this additional step is costly. Also, we don't use Zapier for every automation. Essentially, what I am trying to build is similar to Zapier's "Find Account".

Is this doable w/o Apex? If not, is there any guides you can direct me to learn this part of Apex?

Thanks,

Hi I am new to salesforce trying to write a trigger. I need to update a field in custom object when ever a field Y changes from blank to some value  in contract object the value should be saved to the custom object field X.

Thanks in adavance

I wrote the following
trigger Caseidcustom on Case (after update, after insert) {
    list<Custom object>  i =  new list<Custom object> ();
    
    for(Case cs :trigger.new)
    {
        Case oldCase = trigger.oldMap.get(cs.X);
        
        if(trigger.isInsert) {
            Custom object o = new Custom object ();
            o.Y = cs.X;
            
        }
        
        if(trigger.isUpdate && oldCase != null ) {
            Custom object o = new Custom object ();
            o.Y = cs.X;  
        }
        
    }
}

getting Review all error messages below to correct your data.
Apex trigger Caseidcustom caused an unexpected exception, contact your administrator: Caseidcustom: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: ()
I have two buttons on a Lightning Web Component on a record page. When each is clicked, the code they run is virtually identical, so I want to reuse the code as much as possible. However, I cannot figure out the best way to do it. I can pass the button name into the code, but when I try to put the "let record + fields" code into the switch or conditional if statements, it doesnt work. I need to pass a different field name into the 'let record' statement, depending on which button is pressed. 
 
handleActivateBuyerSide() {
        this.loading = true;
        
        let record = {
            fields: {
                Id: this.recordId,
                VirtualTCStatus_BuyerSide__c: 'Active',        
            },
        };
        updateRecord(record)
            // eslint-disable-next-line no-unused-vars
            .then(() => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Record Is Updated',
                        variant: 'success',
                    }),
                );
                this.loading = false;

            })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error on data save',
                        message: error.message.body,
                        variant: 'error',
                    }),
                );
                this.loading = false;

            });
    }
    handleActivateSellerSide() {
        this.loading = true;
        
        let record = {
            fields: {
                Id: this.recordId,
                VirtualTCStatus_SellerSide__c: 'Active',        
            },
        };
        updateRecord(record)
            // eslint-disable-next-line no-unused-vars
            .then(() => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Record Is Updated',
                        variant: 'success',
                    }),
                );
                this.loading = false;

            })
            .catch(error => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error on data save',
                        message: error.message.body,
                        variant: 'error',
                    }),
                );
                this.loading = false;

            });
    }

 
So if I have two tables lets say Person table & Address table and I want them to be many to many, and I don't want to use a Junction table to create that relationship, is it possible to somehow link them via the record ID in some other method that wouldn't involve junction tables.  With over 100 data tables that have 1,000's of records with the possibilities of infinte many to many relationships needed I just want to see if its possible in anyway to create those many to many relationships without creating a junction table every time.  Thanks!
Please help me it's my humble request. I'm stuck on 5 days. I add server ip ranges but still not working. I follow this link:

http://www.salesforcegeneral.com/salesforce-articles/ip-whitelists-for-salesforce.html
Universal Containers (UC) has a requirement to expose a web service to their business partners. The web service will be used to allow each business partner to query
 UC's Salesforce instance to retrieve the status of orders. The business partner should only be allowed access to orders for which the business partner is the 
 fulfillment vendor. The Architect does not want the business partners to utilize the standard APIs and would prefer a custom API be developed.Which three design 
 elements should the Architect consider in order to ensure the data security of the solution? Choose 3 answers
A. Query the Orders object with Dynamic SOQL based upon the fulfillment ID.
B. Set the Orders object's sharing settings to Private in the Org-Wide Defaults
C. Provide each partner with their own Salesforce login set to API Enabled on the profile. 
D. Develop a custom Apex web service with a fulfillment ID input attribute
E. Develop a custom Apex web service using the "With Sharing" keyword.
So, I've started learning a little apex (having never looked at it before this morning) to help my org with making minor edits to existing functionality (adding variables to conditional statements etc.)

But I've run into a bit of a snag, the original developers (3 years ago or more) did not reach full test coverage (I guess they uploaded directly rather than writing in Salesforce). So I'm now retrospectively tying to write test classes for code I don't necessarily understand in full, so that I can implement my small tweaks. eek!

I've been doing OK, but got stuck on a particular IF, I thought my test class should cover it, but it doesn't! I'm guessing I need to cover some other variable, but I can't for the life of me work out what it is! Anyone that can point out where I'm going wrong would be my personal hero!

Here is the code I'm trying to test:
(I've put my existing code coverage in bold)
List<Payment_Records__c> lstPayment=new List<Payment_Records__c>();
Map<Id,Opportunity> mapoppId=new Map<Id,Opportunity>(); 
List<String> lstprogramTypes=new List<String>();
       
        for(Opportunity opp : opps){
            if(opp.RecordtypeId == schoolRecTypeId || opp.RecordtypeId == fundraisingRecTypeId || opp.RecordtypeId == orgRecTypeId){
                if(!opp.Payment_records_created__c){
                    Payment_Records__c precord = new Payment_Records__c();
                    if(opp.No_of_Years__c == '1'){
                        precord.Amount__c = opp.Amount;
                        if(opp.RecordtypeId == schoolRecTypeId || opp.RecordtypeId == orgRecTypeId){
                            precord.Payment_year__c = opp.Year__c;
                        }
                    }
                    precord.Opportunity__c =opp.Id;
                    lstPayment.add(precord);
                    opp.Payment_records_created__c =true;   
                }              
                else if(opp.Payment_records_created__c==True && oldMap.get(opp.Id).Amount != opp.Amount && opp.No_of_Years__c == '1'){
                    mapOppId.put(opp.Id,opp);
                }
            }       
            if(opp.RecordtypeId == schoolRecTypeId || opp.RecordtypeId== orgRecTypeId){
                if(opp.Package_Prog__c != null){
                    lstprogramTypes.add(opp.Package_Prog__c);
                }
            }
        }
And my test class:
(sorry if it's a mess, I've been refactoring this for well over an hour!)
@isTest static void testpaymentrecordcreation() {
        List<Payment_Records__c> lstPayment=new List<Payment_Records__c>();
        List<Payment_Records__c> new_payments = new List<Payment_Records__c>();
        Id schoolRecTypeId=Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('School Opportunity').getRecordTypeId();
        Id orgRecTypeId=Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('Organisation Opportunity').getRecordTypeId();
        Id fundraisingRecTypeId=Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('Fundraising').getRecordTypeId();
        Id recTypeId=Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('Business Partner Opportunity').getRecordTypeId();
        
        Account acc = new Account(Name='APtest');
        Insert acc;
        
        Programme__c prog = new Programme__c(School__c = acc.Id);
        insert prog;
        
        Programme_Type__c progType = new Programme_Type__c(name = 'Bespoke');
        Insert progtype;
        
        Opportunity opp = new Opportunity (AccountId = acc.Id, Name = 'APtestOpportunity', CloseDate = system.today(),
            StageName = 'Prospecting', Programme__c = prog.Id, Payment_records_created__c = True,
            Amount = 100, Year__c = '2016', No_of_Years__c = '1', RecordTypeId = orgRecTypeId);
        Insert opp;
        
        Payment_Records__c precord = new Payment_Records__c(Opportunity__c = opp.Id, Payment_year__c = opp.Year__c, Amount__c = opp.Amount);
        Insert precord;
            
        Test.StartTest();
        	system.assertNotEquals(False, opp.Payment_records_created__c);
            system.assert(opp.No_of_Years__c == '1');
            system.assert(opp.RecordtypeId == '0120O000000dSyq');
            system.assert(precord.Opportunity__c == opp.Id);
            system.assert(precord.Amount__c == opp.amount);
            system.assert(precord.Payment_year__c == opp.Year__c);
        Test.StopTest();
    }

Again, if you can point out where I'm going wrong, you'd be my personal hero!

A.
I have an Account object that includes another "Payee Agreement" object. In that Payee Agreement Object is a List of "Payee" objects. My issue is that I had created a workflow that tries to send an email to the email address listed in the "Contract Email" field in the Payee object. So if that Account has 3 Payee Agreeements listed, then I need to obtain the three different "Contract emails" listed in the Payee object and send the email to those three address. Obviously, my current workflow cant do that because workflows cant do cross objects. What I did was created another field in Account called "Contract Email 2". Then I tried to update this field with the list of email values in Payee through a trigger. I dont think I wrote the trigger correct. For one,  I think I have the list generated correctly, but I dont think I am physically updating this ACCOUNT field. Also, how do I properly create the "Contract Email 2" field because my understanding is that it will not fill it with a list of values, correct? My trigger is below (if its even needed). If I am doing this whole thing the wrong way, please let me know how I should restart this problem. If I need to explain this problem clearer, please let me know as well. Essentially, I am just hoping that a correct "list" shows up when I select the "recipient" section in my workflow.

trigger PayeeCntractEmail on Payee_Client_Agreements__c (before insert, after update, before delete, after delete) {
    List<Account> accountemailList = new List<Account>();
    String clientNumber = '';
    
    for (Payee_Client_Agreements__c pca : Trigger.New) {
        String payeeAgreementID = pca.Payee_ID__c;
        clientNumber = pca.Client_Number__c;
        Account aObj = [SELECT ID, Contract_Email__c from Account WHERE Client_Number__c =: clientNumber];
        List<Payee__c> contractEmailList = [SELECT Contract_Email__c, Payee_Type__c from Payee__c WHERE Payee_ID__c =: payeeAgreementID];
        
        for(Payee__c email: contractEmailList){
            if(email.Payee_Type__c == 'Broker'){
                aObj.Contract_Email__c = email.Contract_Email__c;
                accountemailList.add(aObj);
            }
        }
        update accountemailList;
        //update aObj.Contract_Email__c;
        
    }
    

}
Hi, I want to start by stating that I am by no means a developer and am not familiar w code....that caveat out of the way, here's my quesiton:

I am fairly new to my org, and there is an integration w a 3rd party whereby they (the 3rd party) will create cases in our org when a document needs review.  When this case is created, there is a link on the case record that will take the user back to the document in the 3rd party system for the user to review.  

Once the issue w the document has been resolved, the user can then go in and close the case, either by clicking the 'Close Case' button, or changing the status to a closed status.  When this happens, there is some sort of trigger that sends a response back to the 3rd party system.  In production this is working fine, but I recently did a sandbox refresh and that 'Case Closed' response, is not being sent.  The inbound part of the integration is working whereby the cases are being created as they should be, and we can update and close, but its that last response that is not working.

I have confirmed the follwoing:
1. the remote site settings have been update to point to the dev/QA environment of the 3rd party (not production)
2. the url that is embedded on the cases when they're created are pointing to their dev/QA environment (not production)
3. There is a case trigger that is supposed to send the response back by calling a 'SendResponse' class and i believe its that part thats failing but no where in the trigger or code can i find specific reference to a url (production or QA).  

What other steps am i missing, keeping in mind Im pretty clueless when it comes to the developer console (i know how to get to it) and code in general.  

Thanks in advance for any sugggestions or thoughts you might have.  
Hello, 

I created this piece of code that reassigns all accounts to the right owner based on the account hierarchy. 
The issue is that this code reassigns 1 node at a time. 

I'd like it to do this until the following query returns 0 : 
SELECT Id,OwnerId,Parent.OwnerId 
FROM Account 
WHERE Account_Owner_Parent_Owner__c = TRUE 
AND IsExcludedFromRealign = FALSE
Current Code
global class ReassignAccounts implements Schedulable {
    
    global void execute(SchedulableContext ctx) {
        List<Account> AccList = [SELECT Id,OwnerId,Parent.OwnerId FROM Account WHERE Account_Owner_Parent_Owner__c = TRUE AND IsExcludedFromRealign = FALSE];
        
        for(Account Acc : AccList){    
            Acc.OwnerId = Acc.Parent.OwnerId ;
        }
        
        update AccList; }
    
}

Can I add a while [SELECT Id,OwnerId,Parent.OwnerId FROM Account WHERE Account_Owner_Parent_Owner__c = TRUE AND IsExcludedFromRealign = FALSE] > 0, do ... ? 

Thanks, 

Nathan