• Anand Jeevakan
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 12
    Replies
Hi,
I'm  a newbie to Tableau CRM.
I created a simple dataset for Task object - did not add any lookup fields
Tried to create a line dashboard to display number of tasks grouped by activitydate.
The chart is picking only for last one year and not before that. There are no filters in chart or the dataset.

When I create a regular report / chart, the data is spread across 3 years. 

Would like to know if there is any default setting that need to be updated to display older data.
Hi, 
In NPSP, there is a concept called "Address Management" where the all the contacts of a single household will be updated with the same address.
https://powerofus.force.com/s/article/NPSP-Add-Addresses-to-a-Household

Please let me know if there is a process to do the same in health cloud.

Thanks
Anand
Does health cloud lightning console comes along with Health cloud package? I have installed health cloud package, not able to see this console. When I try to create a console, there is no option to add household (acount contact relationship object) to the console. 
I'm using system admin profile with required permission sets
Hi,
I'm trying to create a unmanaged package. When I click on upload, it throws the error:
Upload Failed
There are problems that prevent this package from being uploaded.
However, no error is displayed.
Any help is appreciated.
I'm trying to merge two accounts in apex.

Error: Invalid field IsCustomerPortal for merge. 

Below the method:
Though I try to skip the field in map in line number 14, the merge function still consider this field and throws the error. 
My org do not have communities enabled.
Any help is appreciated.
private static void MergeAccount(Id AccId,Id dupAccId){
        if ((AccId==null)||(dupAccId==null)) return;
        if (AccId==dupAccId) return;
        String querystring = 'select  ';
        String selectedObject = 'Account';
        Map<String, Schema.SObjectType> gdMap = Schema.getGlobalDescribe();
        Schema.Describesobjectresult dsr = gdMap.get(selectedObject).getDescribe();
        
		//Added below  on 15Dec20 - to ignore iscustomerportal while merging
		Map<String, Schema.SObjectField> tempMap = dsr.fields.getMap();
		//Map<String, Schema.SObjectField> fieldMap = dsr.fields.getMap();
		Map<String, Schema.SObjectField> fieldMap = new Map<String, Schema.SObjectField>();
		
		for (String fieldname: tempMap.keySet()){
                if(fieldName != 'IsCustomerPortal')
                    fieldmap.put(fieldname, tempMap.get(fieldname));
		}
		
		
        for(String fieldName : fieldMap.keySet()) {
			   if(fieldMap.get(fieldName).getDescribe().isUpdateable())
					querystring += ' ' + fieldName +',';
		   
        }
        querystring = querystring.left(querystring.length()-1);
        querystring += ' from Account where Id = :AccId OR Id = :dupAccId';
        List<Account> records = new List<Account>();
        List<Account> duplicates = new List<Account>();
		system.debug('querystring '+querystring);
        for (Account acc : (List<Account>)database.query(querystring)){
            if (AccId==acc.Id)
                records.add(acc);
            else if (dupAccId==acc.Id)
                duplicates.add(acc);
        }
        if ((records.isEmpty())||(duplicates.isEmpty())) return;
        
        set<string> billingAddressFields = new set<string>(); 
        billingAddressFields.add('BillingStreet'); 
        billingAddressFields.add('BillingCity');
        billingAddressFields.add('BillingState');
        billingAddressFields.add('BillingPostalCode');
        billingAddressFields.add('BillingCountry'); 
                
        set<string> shippingAddressFields = new set<string>(); 
        shippingAddressFields.add('shippingStreet'); 
        shippingAddressFields.add('shippingCity');
        shippingAddressFields.add('shippingState');
        shippingAddressFields.add('shippingPostalCode');
        shippingAddressFields.add('shippingCountry'); 
        
        if (string.isBlank(records.get(0).Description))
            records.get(0).Description = duplicates.get(0).Description;
        else if (string.isNotBlank(duplicates.get(0).Description))
            records.get(0).Description = records.get(0).Description+'\r\n'+duplicates.get(0).Description;
        for (Account record: records) {
            ////
            String recordid = record.Id;
			record.iscustomerportal = false;
            for (Account d :duplicates) {
               boolean nonBlankBillingAddress = false;
               boolean nonBlankShippingAddress = false;
               for(String fieldName : fieldMap.keySet()) {				   
				  if(fieldMap.get(fieldName).getDescribe().isUpdateable()) {
					// Need to skip address here, but keep track of address fields and merge if ALL address fields blank
					 if (!billingAddressFields.contains(fieldName) && !shippingAddressFields.contains(fieldName)) {
						boolean continueProcessing = true;
						// Don't update parentId field with record id of master
						if (fieldName.equalsIgnoreCase('ParentId'))
						   if (d.get(fieldName) != null)
							  if (d.get(fieldName) == recordid) 
								 continueProcessing = false;
						if (d.get(fieldName) != null && record.get(fieldName) == null && continueProcessing)
						   record.put(fieldName, d.get(fieldName));
						else if(fieldMap.get(fieldName).getDescribe().getType() == Schema.DisplayType.Boolean)
						   if (continueProcessing && d.get(fieldName) == true)
							  record.put(fieldName, d.get(fieldName));
					 }
					 else
						if (record.get(fieldName) != null && billingAddressFields.contains(fieldName))
						   nonBlankBillingAddress = true;
						else if (record.get(fieldName) != null && shippingAddressFields.contains(fieldName))
						   nonBlankShippingAddress = true;
				  }
				   
               }
               // Set Address fields if blank
               if (!nonBlankBillingAddress) {
                    record.put('BillingStreet', d.get('BillingStreet'));
                    record.put('BillingCity', d.get('BillingCity'));
                    record.put('BillingState', d.get('BillingState'));
                    record.put('BillingPostalCode', d.get('BillingPostalCode'));
                    record.put('BillingCountry', d.get('BillingCountry'));
               }
               if (!nonBlankShippingAddress) {
                    record.put('ShippingStreet', d.get('ShippingStreet'));
                    record.put('ShippingCity', d.get('ShippingCity'));
                    record.put('ShippingState', d.get('ShippingState'));
                    record.put('ShippingPostalCode', d.get('ShippingPostalCode'));
                    record.put('ShippingCountry', d.get('ShippingCountry'));                    
               }
               
           }
            ////
            Boolean  completeMerge = false;          
            if (duplicates.size() < 3 && duplicates.size() > 0)    {
                Database.MergeResult[] results = Database.merge(record, duplicates, false);
                
                for(Database.MergeResult res : results) {
                    if (res.isSuccess()) {
                        // Get the master ID from the result and validate it
                        completeMerge  = true;
                        System.debug('Master record ID: ' + res.getId());
                    }
                    else {
                        for(Database.Error err : res.getErrors()) {
                            // Write each error to the debug output
                            System.debug(err.getMessage());
                        }
                    }
                }
            } else if (duplicates.size() < 3) 
                System.debug('Batch Merge: skip records too many for master record: ' + record.Id);
            else
                System.debug('Batch Merge: skip no duplicates for master record: ' + record.Id);
        }
        update records;
    }
    
}

 
Hi,
Getting this error while trying to delete a record in lightning (action):

Uncaught Action failed: force:recordData$controller$deleteRecord [Must load record in force:recordData before delete.]
Callback failed: aura://ComponentController/ACTION$getComponent
Callback failed: aura://ComponentController/ACTION$getComponent

Component code
<aura:component implements="force:lightningQuickAction,force:hasRecordId">
	<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
    <aura:handler name="render" value="{!this}" action="{!c.cancelContactMerge}"/>
         <aura:attribute name="recordId" type="Id" />
        <aura:attribute name="record" type="Search_Merge_Duplicate_Contact_Pair__c" />
        <aura:attribute name="simpleRecord" type="Search_Merge_Duplicate_Contact_Pair__c" />
    
        <force:recordData aura:id="recordHandler"
                  recordId="{!v.recordId}"
                  targetRecord="{!v.record}"
                  targetFields="{!v.simpleRecord}"
                  layoutType="FULL"
                  />
</aura:component>

JS Controller:
({
	myAction : function(component, event, helper) {
      
	},
    
    cancelContactMerge : function(component, event, helper) {
        var acctId = component.get("v.simpleRecord.Account__c");
        component.find("recordHandler").deleteRecord($A.getCallback(function(deleteResult) {
            // NOTE: If you want a specific behavior(an action or UI behavior) when this action is successful 
            // then handle that in a callback (generic logic when record is changed should be handled in recordUpdated event handler)
            if (deleteResult.state === "SUCCESS" || deleteResult.state === "DRAFT") {
                // record is deleted
                console.log("Record is deleted.");
                // Close the Quick Action
                $A.get("e.force:closeQuickAction").fire();
                // Navigate back to Account to Keep
                var navEvt = $A.get("e.force:navigateToSObject");
    					navEvt.setParams({
      					"recordId": acctId
   						 });
    			navEvt.fire();
                
            } else if (deleteResult.state === "INCOMPLETE") {
                console.log("User is offline, device doesn't support drafts.");
            } else if (deleteResult.state === "ERROR") {
                console.log('Problem deleting record, error: ' + JSON.stringify(deleteResult.error));
            } else {
                console.log('Unknown problem, state: ' + deleteResult.state + ', error: ' + JSON.stringify(deleteResult.error));
            }
        }));
            

	}
 
    
})

Tried the code  here (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_delete_record.htm) - it worked but the requirement doesn't want a confirmation pop up.

Thank you.
 

The task is convert a classic button into lightning action. The existing apex controller is unchanged except for adding @AuraEnabled for webservice that will return a list to the client side controller. There are 3 scenarios - the client side controller will alert based on the message received from the apex controller:

There are 2 failure scenarios –  able to display them as alerts
There is 1 success scenario – The alert is not triggering for this case.

Apex controller:

global without sharing class giftBatchHelper {

    public boolean tagPendingGifts(Id BatchId){
        boolean ret = true;
        this.errorDesc = '';
        this.numOpps = 0;
        try{
            if (string.isNotBlank(BatchId)){
               List<Opportunity> lstOppCheck = [select Id from Opportunity where Gift_Batch__c = :BatchId];
               if (lstOppCheck != null)
                  if (lstOppCheck.size() > 0) {
                     this.errorDesc = 'This batch already has Gifts assigned.  You may not run the batch assignment process more than once for a given Gift Batch.';
                     ret = false;
                     return ret;
                  }
               this.errorDesc = 'There are no Posted Opportunities without a Gift Batch assignment.';
               List<Opportunity> lstOppUPdate = [select Id, Gift_Batch__c  from Opportunity where Gift_Batch__c = null AND StageName = 'Posted' AND RecordType.Name = 'Donation'];
               if (lstOppUPdate != null)
                  if (lstOppUPdate.size() > 0) {
                     for (Opportunity o: lstOppUPdate ) 
                        o.Gift_Batch__c = BatchId;
                     Update lstOppUPdate;
                     this.numOpps = lstOppUPdate.size();
                     this.errorDesc = '';
                  }
            }  
        }
        catch(Exception exc){
            this.errorDesc = exc.getMessage();
            ret = false;
        }
        return ret;
    }
@AuraEnabled
    webservice static list<string> TagPendingGiftsForBatch(string strBatchId){    
        Id BatchId = Id.valueOf(strBatchId);
        if (BatchId ==null) return new list<string>{'Error: Invalid Batch Id',''};
        giftBatchHelper objgiftBatchHelper  = new giftBatchHelper();
        objgiftBatchHelper.tagPendingGifts(BatchId);
        return new list<string>{objgiftBatchHelper.errorDesc,string.valueOf(objgiftBatchHelper.numOpps)};
    }

}

 

Client side controller:

({
    "echo" : function(cmp) {
        // create a one-time use instance of the serverEcho action
        // in the server-side controller
        var action = cmp.get("c.TagPendingGiftsForBatch");

        var varRecordId = cmp.get("v.recordId");
        //alert('varRecordId: ' + varRecordId);
        action.setParams({  strBatchId : varRecordId  });
        
        //alert('before callback');
        
        action.setCallback(this, function(response) {
            
            alert('inside call back');
            var result = response.getReturnValue();
            //if(response.getReturnValue() != null)
            alert('result[0] ' + result[0]);
            alert('result[1] ' + result[1]);
            if(result[1]==0)
            {
                var result = response.getReturnValue();
                //var retMessage = result[0];
                //alert('result[1] ' + result[1]);
                //alert('result[0].length ' + result[0].length);
                //alert('result.length' + result.length);
            
                if(result.length === 2)
                {
                    if(result[0].length > 0) 
                    {
                        alert(result[0]);                         
                    }
                }
            }
            else if(result[1]>0)
            {
                alert('Gift(s) updated with batch:');
            }

            else
            {
                alert('Error: Batch Id is empty.');
            }
            });
        
        $A.enqueueAction(action);
        $A.get("e.force:closeQuickAction").fire();
    }
})


The bold italics section should work when there is a value in result[1] - however, the flow is getting inside the setCallback i.e. the alert('inside call back'); doesn't throw the alert.

Please let me know where there issue is...

I'm trying to deploy a batch apex and its test class. Everything works fine in dev and I get 93% coverage. When I try to deploy, I get:


Error:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.testPrimaryCommunityUser.testPrimaryCommunityUser: line 19, column 1"

Test Class Code:

@isTest
private class testBatchLeadPrimaryCommunityUser {
    static testMethod void testBatchLeadPrimaryCommunityUser(){
       
        Group testGroup = new Group(Name = 'Queue', Type = 'Queue');
        insert testGroup;

        QueueSObject testQueue = new QueueSObject(QueueID = testGroup.id, SobjectType = 'Lead');
        insert testQueue;
       
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
    
 
 
        User userobj = new User();
        //userobj.IsActive = True;
        userobj.Username = 'fivestarsitetesting12ka4@config-5sqc.cs9.force.com';
        userobj.LastName = 'Site Guest 12ka4';
        userobj.Email = 'doug.ricks12ka4@lansdalegroup.com';
        userobj.Alias = '12ka4';
        userobj.CommunityNickname = 'FiveStarSite123';
        userobj.TimeZoneSidKey = 'GMT';
        userobj.LocaleSidKey = 'en_US';
        userobj.EmailEncodingKey = 'ISO-8859-1';
        userobj.ProfileId = p.Id;
        userobj.LanguageLocaleKey = 'en_US';
        insert userobj;

        System.runAs ( userobj ) {
   Account acc = new Account();
            acc.Name = 'New Account';
            acc.Primary_Community_User__c = userobj.Id;
            acc.RecordTypeId = (Schema.SObjectType.account.getRecordTypeInfosByName().get('Five Star Community').getRecordTypeId());
            insert acc;
           
            Date startDate = Date.newInstance(2000, 1, 1);
           
            Lead led = new Lead();
            led.ownerId = testGroup.Id;
            led.LeadSource = 'Advertising - Cable Television';
            led.Inquirer_First_Name__c = 'fname';
            led.Inquirer_Last_Name__c = 'lname';
            led.Inquirer_Relationship_To_Prospect__c = 'Friend';
            led.Community__c = acc.Id;
            led.LastName = 'LastName';
            led.Status = 'Pending Qualification';
            led.Inquiry_Date__c = startDate;
            insert led;
       
        //Start Test
        Test.startTest();
   
        BatchLeadPrimaryCommunityUser exeBatch = new BatchLeadPrimaryCommunityUser(100);
        Database.executeBatch(exeBatch);

        Test.stopTest();

        }
       
       

}
}

Please help
Does health cloud lightning console comes along with Health cloud package? I have installed health cloud package, not able to see this console. When I try to create a console, there is no option to add household (acount contact relationship object) to the console. 
I'm using system admin profile with required permission sets
Hi,
I'm trying to create a unmanaged package. When I click on upload, it throws the error:
Upload Failed
There are problems that prevent this package from being uploaded.
However, no error is displayed.
Any help is appreciated.
I'm trying to merge two accounts in apex.

Error: Invalid field IsCustomerPortal for merge. 

Below the method:
Though I try to skip the field in map in line number 14, the merge function still consider this field and throws the error. 
My org do not have communities enabled.
Any help is appreciated.
private static void MergeAccount(Id AccId,Id dupAccId){
        if ((AccId==null)||(dupAccId==null)) return;
        if (AccId==dupAccId) return;
        String querystring = 'select  ';
        String selectedObject = 'Account';
        Map<String, Schema.SObjectType> gdMap = Schema.getGlobalDescribe();
        Schema.Describesobjectresult dsr = gdMap.get(selectedObject).getDescribe();
        
		//Added below  on 15Dec20 - to ignore iscustomerportal while merging
		Map<String, Schema.SObjectField> tempMap = dsr.fields.getMap();
		//Map<String, Schema.SObjectField> fieldMap = dsr.fields.getMap();
		Map<String, Schema.SObjectField> fieldMap = new Map<String, Schema.SObjectField>();
		
		for (String fieldname: tempMap.keySet()){
                if(fieldName != 'IsCustomerPortal')
                    fieldmap.put(fieldname, tempMap.get(fieldname));
		}
		
		
        for(String fieldName : fieldMap.keySet()) {
			   if(fieldMap.get(fieldName).getDescribe().isUpdateable())
					querystring += ' ' + fieldName +',';
		   
        }
        querystring = querystring.left(querystring.length()-1);
        querystring += ' from Account where Id = :AccId OR Id = :dupAccId';
        List<Account> records = new List<Account>();
        List<Account> duplicates = new List<Account>();
		system.debug('querystring '+querystring);
        for (Account acc : (List<Account>)database.query(querystring)){
            if (AccId==acc.Id)
                records.add(acc);
            else if (dupAccId==acc.Id)
                duplicates.add(acc);
        }
        if ((records.isEmpty())||(duplicates.isEmpty())) return;
        
        set<string> billingAddressFields = new set<string>(); 
        billingAddressFields.add('BillingStreet'); 
        billingAddressFields.add('BillingCity');
        billingAddressFields.add('BillingState');
        billingAddressFields.add('BillingPostalCode');
        billingAddressFields.add('BillingCountry'); 
                
        set<string> shippingAddressFields = new set<string>(); 
        shippingAddressFields.add('shippingStreet'); 
        shippingAddressFields.add('shippingCity');
        shippingAddressFields.add('shippingState');
        shippingAddressFields.add('shippingPostalCode');
        shippingAddressFields.add('shippingCountry'); 
        
        if (string.isBlank(records.get(0).Description))
            records.get(0).Description = duplicates.get(0).Description;
        else if (string.isNotBlank(duplicates.get(0).Description))
            records.get(0).Description = records.get(0).Description+'\r\n'+duplicates.get(0).Description;
        for (Account record: records) {
            ////
            String recordid = record.Id;
			record.iscustomerportal = false;
            for (Account d :duplicates) {
               boolean nonBlankBillingAddress = false;
               boolean nonBlankShippingAddress = false;
               for(String fieldName : fieldMap.keySet()) {				   
				  if(fieldMap.get(fieldName).getDescribe().isUpdateable()) {
					// Need to skip address here, but keep track of address fields and merge if ALL address fields blank
					 if (!billingAddressFields.contains(fieldName) && !shippingAddressFields.contains(fieldName)) {
						boolean continueProcessing = true;
						// Don't update parentId field with record id of master
						if (fieldName.equalsIgnoreCase('ParentId'))
						   if (d.get(fieldName) != null)
							  if (d.get(fieldName) == recordid) 
								 continueProcessing = false;
						if (d.get(fieldName) != null && record.get(fieldName) == null && continueProcessing)
						   record.put(fieldName, d.get(fieldName));
						else if(fieldMap.get(fieldName).getDescribe().getType() == Schema.DisplayType.Boolean)
						   if (continueProcessing && d.get(fieldName) == true)
							  record.put(fieldName, d.get(fieldName));
					 }
					 else
						if (record.get(fieldName) != null && billingAddressFields.contains(fieldName))
						   nonBlankBillingAddress = true;
						else if (record.get(fieldName) != null && shippingAddressFields.contains(fieldName))
						   nonBlankShippingAddress = true;
				  }
				   
               }
               // Set Address fields if blank
               if (!nonBlankBillingAddress) {
                    record.put('BillingStreet', d.get('BillingStreet'));
                    record.put('BillingCity', d.get('BillingCity'));
                    record.put('BillingState', d.get('BillingState'));
                    record.put('BillingPostalCode', d.get('BillingPostalCode'));
                    record.put('BillingCountry', d.get('BillingCountry'));
               }
               if (!nonBlankShippingAddress) {
                    record.put('ShippingStreet', d.get('ShippingStreet'));
                    record.put('ShippingCity', d.get('ShippingCity'));
                    record.put('ShippingState', d.get('ShippingState'));
                    record.put('ShippingPostalCode', d.get('ShippingPostalCode'));
                    record.put('ShippingCountry', d.get('ShippingCountry'));                    
               }
               
           }
            ////
            Boolean  completeMerge = false;          
            if (duplicates.size() < 3 && duplicates.size() > 0)    {
                Database.MergeResult[] results = Database.merge(record, duplicates, false);
                
                for(Database.MergeResult res : results) {
                    if (res.isSuccess()) {
                        // Get the master ID from the result and validate it
                        completeMerge  = true;
                        System.debug('Master record ID: ' + res.getId());
                    }
                    else {
                        for(Database.Error err : res.getErrors()) {
                            // Write each error to the debug output
                            System.debug(err.getMessage());
                        }
                    }
                }
            } else if (duplicates.size() < 3) 
                System.debug('Batch Merge: skip records too many for master record: ' + record.Id);
            else
                System.debug('Batch Merge: skip no duplicates for master record: ' + record.Id);
        }
        update records;
    }
    
}

 
Hi,
Getting this error while trying to delete a record in lightning (action):

Uncaught Action failed: force:recordData$controller$deleteRecord [Must load record in force:recordData before delete.]
Callback failed: aura://ComponentController/ACTION$getComponent
Callback failed: aura://ComponentController/ACTION$getComponent

Component code
<aura:component implements="force:lightningQuickAction,force:hasRecordId">
	<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
    <aura:handler name="render" value="{!this}" action="{!c.cancelContactMerge}"/>
         <aura:attribute name="recordId" type="Id" />
        <aura:attribute name="record" type="Search_Merge_Duplicate_Contact_Pair__c" />
        <aura:attribute name="simpleRecord" type="Search_Merge_Duplicate_Contact_Pair__c" />
    
        <force:recordData aura:id="recordHandler"
                  recordId="{!v.recordId}"
                  targetRecord="{!v.record}"
                  targetFields="{!v.simpleRecord}"
                  layoutType="FULL"
                  />
</aura:component>

JS Controller:
({
	myAction : function(component, event, helper) {
      
	},
    
    cancelContactMerge : function(component, event, helper) {
        var acctId = component.get("v.simpleRecord.Account__c");
        component.find("recordHandler").deleteRecord($A.getCallback(function(deleteResult) {
            // NOTE: If you want a specific behavior(an action or UI behavior) when this action is successful 
            // then handle that in a callback (generic logic when record is changed should be handled in recordUpdated event handler)
            if (deleteResult.state === "SUCCESS" || deleteResult.state === "DRAFT") {
                // record is deleted
                console.log("Record is deleted.");
                // Close the Quick Action
                $A.get("e.force:closeQuickAction").fire();
                // Navigate back to Account to Keep
                var navEvt = $A.get("e.force:navigateToSObject");
    					navEvt.setParams({
      					"recordId": acctId
   						 });
    			navEvt.fire();
                
            } else if (deleteResult.state === "INCOMPLETE") {
                console.log("User is offline, device doesn't support drafts.");
            } else if (deleteResult.state === "ERROR") {
                console.log('Problem deleting record, error: ' + JSON.stringify(deleteResult.error));
            } else {
                console.log('Unknown problem, state: ' + deleteResult.state + ', error: ' + JSON.stringify(deleteResult.error));
            }
        }));
            

	}
 
    
})

Tried the code  here (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_delete_record.htm) - it worked but the requirement doesn't want a confirmation pop up.

Thank you.
 
When passing values into the dependentPicklists lightning component in flow, the controlling value populates but the dependent one does not. Both values are populated on the source record.

User-added image

The task is convert a classic button into lightning action. The existing apex controller is unchanged except for adding @AuraEnabled for webservice that will return a list to the client side controller. There are 3 scenarios - the client side controller will alert based on the message received from the apex controller:

There are 2 failure scenarios –  able to display them as alerts
There is 1 success scenario – The alert is not triggering for this case.

Apex controller:

global without sharing class giftBatchHelper {

    public boolean tagPendingGifts(Id BatchId){
        boolean ret = true;
        this.errorDesc = '';
        this.numOpps = 0;
        try{
            if (string.isNotBlank(BatchId)){
               List<Opportunity> lstOppCheck = [select Id from Opportunity where Gift_Batch__c = :BatchId];
               if (lstOppCheck != null)
                  if (lstOppCheck.size() > 0) {
                     this.errorDesc = 'This batch already has Gifts assigned.  You may not run the batch assignment process more than once for a given Gift Batch.';
                     ret = false;
                     return ret;
                  }
               this.errorDesc = 'There are no Posted Opportunities without a Gift Batch assignment.';
               List<Opportunity> lstOppUPdate = [select Id, Gift_Batch__c  from Opportunity where Gift_Batch__c = null AND StageName = 'Posted' AND RecordType.Name = 'Donation'];
               if (lstOppUPdate != null)
                  if (lstOppUPdate.size() > 0) {
                     for (Opportunity o: lstOppUPdate ) 
                        o.Gift_Batch__c = BatchId;
                     Update lstOppUPdate;
                     this.numOpps = lstOppUPdate.size();
                     this.errorDesc = '';
                  }
            }  
        }
        catch(Exception exc){
            this.errorDesc = exc.getMessage();
            ret = false;
        }
        return ret;
    }
@AuraEnabled
    webservice static list<string> TagPendingGiftsForBatch(string strBatchId){    
        Id BatchId = Id.valueOf(strBatchId);
        if (BatchId ==null) return new list<string>{'Error: Invalid Batch Id',''};
        giftBatchHelper objgiftBatchHelper  = new giftBatchHelper();
        objgiftBatchHelper.tagPendingGifts(BatchId);
        return new list<string>{objgiftBatchHelper.errorDesc,string.valueOf(objgiftBatchHelper.numOpps)};
    }

}

 

Client side controller:

({
    "echo" : function(cmp) {
        // create a one-time use instance of the serverEcho action
        // in the server-side controller
        var action = cmp.get("c.TagPendingGiftsForBatch");

        var varRecordId = cmp.get("v.recordId");
        //alert('varRecordId: ' + varRecordId);
        action.setParams({  strBatchId : varRecordId  });
        
        //alert('before callback');
        
        action.setCallback(this, function(response) {
            
            alert('inside call back');
            var result = response.getReturnValue();
            //if(response.getReturnValue() != null)
            alert('result[0] ' + result[0]);
            alert('result[1] ' + result[1]);
            if(result[1]==0)
            {
                var result = response.getReturnValue();
                //var retMessage = result[0];
                //alert('result[1] ' + result[1]);
                //alert('result[0].length ' + result[0].length);
                //alert('result.length' + result.length);
            
                if(result.length === 2)
                {
                    if(result[0].length > 0) 
                    {
                        alert(result[0]);                         
                    }
                }
            }
            else if(result[1]>0)
            {
                alert('Gift(s) updated with batch:');
            }

            else
            {
                alert('Error: Batch Id is empty.');
            }
            });
        
        $A.enqueueAction(action);
        $A.get("e.force:closeQuickAction").fire();
    }
})


The bold italics section should work when there is a value in result[1] - however, the flow is getting inside the setCallback i.e. the alert('inside call back'); doesn't throw the alert.

Please let me know where there issue is...

Hello all -

I am trying to merge two accounts. Both the accounts, I am using a describe call to get all the fields. In my scenario I am checking if the master account has blank values in any of the fields, I am filling it with the losing account values. However when I merge (Database.merge(masteraccount,loseraccount), I get this error:

salesforce MERGE_FAILED, Invalid field IsPartner for merge: []

I checked few forums, but hardly got anything online.

Can anyone throw some light?

Regards,
Priyanka.
I'm trying to deploy a batch apex and its test class. Everything works fine in dev and I get 93% coverage. When I try to deploy, I get:


Error:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.testPrimaryCommunityUser.testPrimaryCommunityUser: line 19, column 1"

Test Class Code:

@isTest
private class testBatchLeadPrimaryCommunityUser {
    static testMethod void testBatchLeadPrimaryCommunityUser(){
       
        Group testGroup = new Group(Name = 'Queue', Type = 'Queue');
        insert testGroup;

        QueueSObject testQueue = new QueueSObject(QueueID = testGroup.id, SobjectType = 'Lead');
        insert testQueue;
       
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
    
 
 
        User userobj = new User();
        //userobj.IsActive = True;
        userobj.Username = 'fivestarsitetesting12ka4@config-5sqc.cs9.force.com';
        userobj.LastName = 'Site Guest 12ka4';
        userobj.Email = 'doug.ricks12ka4@lansdalegroup.com';
        userobj.Alias = '12ka4';
        userobj.CommunityNickname = 'FiveStarSite123';
        userobj.TimeZoneSidKey = 'GMT';
        userobj.LocaleSidKey = 'en_US';
        userobj.EmailEncodingKey = 'ISO-8859-1';
        userobj.ProfileId = p.Id;
        userobj.LanguageLocaleKey = 'en_US';
        insert userobj;

        System.runAs ( userobj ) {
   Account acc = new Account();
            acc.Name = 'New Account';
            acc.Primary_Community_User__c = userobj.Id;
            acc.RecordTypeId = (Schema.SObjectType.account.getRecordTypeInfosByName().get('Five Star Community').getRecordTypeId());
            insert acc;
           
            Date startDate = Date.newInstance(2000, 1, 1);
           
            Lead led = new Lead();
            led.ownerId = testGroup.Id;
            led.LeadSource = 'Advertising - Cable Television';
            led.Inquirer_First_Name__c = 'fname';
            led.Inquirer_Last_Name__c = 'lname';
            led.Inquirer_Relationship_To_Prospect__c = 'Friend';
            led.Community__c = acc.Id;
            led.LastName = 'LastName';
            led.Status = 'Pending Qualification';
            led.Inquiry_Date__c = startDate;
            insert led;
       
        //Start Test
        Test.startTest();
   
        BatchLeadPrimaryCommunityUser exeBatch = new BatchLeadPrimaryCommunityUser(100);
        Database.executeBatch(exeBatch);

        Test.stopTest();

        }
       
       

}
}

Please help
<apex:stylesheet value="{!$Resource.relatedList}" />
....
<apex:pageBlock title="Assessment Service Area">
  <apex:pageBlockTable value="{!getASAList}" var="asmtServiceArea">
    <apex:column styleClass = "link" value="{!asmtServiceArea.Name}" />
    <apex:column styleClass = "link" value="{!asmtServiceArea.Service_Area__c}"/>
    <apex:column styleClass = "link" value="{!asmtServiceArea.Service_Area_Level__c}"/>
    <apex:column styleClass = "link" value="{!asmtServiceArea.Minutes__c}"/>
  </apex:pageBlockTable>

I tried CSS file stored in Static resource as well as inline stylesheet, but the styles are not reflected in the text inside the table columns. Please help!