• Herish Surendran
  • NEWBIE
  • 90 Points
  • Member since 2019


  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 34
    Replies
Hi All,

I have a MultiSelectPickList field in User and Picklist in custom object. I need to compare such a way that piclist value is present in MultiSelectPickList in validation rule. I tried using INCLUDES($User.MultiSelectPickList,TEXT(Picklist)) but I got Error: Incorrect parameter type for function 'INCLUDES()'. Expected Text Literal, received Text. I analised this error and i got solution from here
https://ipfs-sec.stackexchange.cloudflare-ipfs.com/salesforce/A/question/148489.html to use triggers. 

Now my question is, is there any way to compare rather than using triggers. is there any  way to compare in  Condition Formula in validation rule 

Thanks,
sai
 
I tried going through lwc receipe github url. https://github.com/trailheadapps/lwc-recipes/blob/master/force-app/main/default/lwc/lmsSubscriberWebComponent/__tests__/lmsSubscriberWebComponent.test.js

But it didn't help me. 
A table in componentName.html
 
<table style="border-collapse: collapse; width: 100%;">
                                <tr>
                                    <td style="border: 1px solid grey; text-align: left; padding: 8px;">
                                        <input type="radio" id="Phone" name="verificationMethod" value={phone} onchange={selectMethod}/>
                                        <label class="slds-text-heading_small">&nbsp;{phone}</label>
                                    </td>
                                </tr>
                            </table>

componentName.js
 
selectMethod(event){
        this.selectedMethod = event.target.id;
    }

When the select method executes, the value of selectedMethod property becomes Phone-57 instead of Phone.

So I changed the function to 
 
selectMethod(event){
        this.selectedMethod = event.target.id.replace('-57','');
    }

Can anyone please tell why this is happening.
We are using Single sign on to login to Salesforce. We'd like to make an API callout from Salesforce to an internal API. To authenticate to access the API, we'd like to use the session token from the single sign-on to send with the HttpRequest so that the service can validate that the request is coming from a reliable user from salesforce. How to get the user session token that the single sign-on provider sends using Apex?

Any guidance would be helpful. Thank you!
I am getting error 

Challenge Not yet complete... here's what's wrong:
We can’t find the correct settings in the component boatReviews HTML. Review the div tag related to when there are reviews to display, including the classes and styles, according to the requirements.

in LWC superbadge challenge

here is my code

<--boatReviews.html -->
<template>
    <div class="slds-scrollable--y">
        <template if:true={reviewsToShow}>
            <template if:true={isLoading}>
                <lightning-spinner alternative-text="Loading" size="small" variant="brand"></lightning-spinner>
            </template>
           <ul class="slds-feed__list">
               <!-- start iteration -->
               <template for:each={boatReviews.data} for:item="boatReview">
                    <li class="slds-feed__item" key={boatReview.Id}>
                        <article class="slds-post">
                            <header class="slds-post__header slds-media">
                                <div class="slds-media__figure">
                                    <!-- display the creator’s picture -->
                                    <lightning-avatar variant="circle" src={boatReview.CreatedBy.SmallPhotoUrl}>

                                    </lightning-avatar>
                                </div>
                                <div class="slds-media__body">
                                    <div class="slds-grid slds-grid_align-spread slds-has-flexi-truncate">
                                        <p>
                                            <a onclick={navigateToRecord}
                                                data-record-id={boatReview.CreatedBy.Id}
                                                title={boatReview.CreatedBy.Name}>{boatReview.CreatedBy.Name}</a>
                                            
                                            <span>
                                                <!-- display creator’s company name -->
                                               - {boatReview.CreatedBy.CompanyName}
                                            </span>
                                        </p>
                                    </div>
                                    <p class="slds-text-body_small">
                                        <!-- display created  date -->
                                        <lightning-formatted-date-time value={boatReview.CreatedDate}>
                                        </lightning-formatted-date-time>
                                        
                                    </p>
                                </div>
                            </header>
                            <div class="slds-text-longform">
                                <p class="slds-text-title_caps">
                                    <!-- display Name -->
                                    {boatReview.Name}
                                </p>
                                <!-- display Comment__c -->
                                {boatReview.Comment__c}
                            </div>
                            <!-- display five star rating on readonly mode -->
                            <c-five-star-rating read-only="true" value={boatReview.Rating__c}></c-five-star-rating>
                        </article>
                    </li>
            </template>
               <!-- end iteration -->
           </ul>
        </template>
        <template if:false={reviewsToShow}>
            <div class="slds-align_absolute-center">
                No reviews available
            </div>            
        </template>
    </div>
</template>

<-- boatReviews.js -->
import {
    LightningElement,
    api,
    track
} from 'lwc';
import getAllReviews from '@salesforce/apex/BoatDataService.getAllReviews';
import {
    NavigationMixin
} from 'lightning/navigation';
import {
    refreshApex
} from '@salesforce/apex';

export default class BoatReviews extends NavigationMixin(LightningElement) {
    // Private
    boatId;
    error;
    boatReviews = [];
    isLoading = false;

    // Getter and Setter to allow for logic to run on recordId change
    @api
    get recordId() {
        return this.boatId;
    }

    set recordId(value) {
        //sets boatId attribute
        this.setAttribute('boatId', value);
        //sets boatId assignment
        this.boatId = value;
        //get reviews associated with boatId
        this.getReviews();
    }

    // Getter to determine if there are reviews to display
    get reviewsToShow() {
        return this.boatReviews && this.boatReviews.length > 0 ? true : false;
    }

    // Public method to force a refresh of the reviews invoking getReviews
    @api
    refresh() {
        refreshApex(this.getReviews());
    }

    // Imperative Apex call to get reviews for given boat
    // returns immediately if boatId is empty or null
    // sets isLoading to true during the process and false when it’s completed
    // Gets all the boatReviews from the result, checking for errors.
    getReviews() {
        if (this.boatId == null || this.boatId == '') {
            return;
        }
        this.isLoading = true;
        this.error = undefined;
        getAllReviews({
                boatId: this.recordId
            })
            .then(result => {
                this.boatReviews = result;
                this.isLoading = false;
            }).catch(error => {
                this.error = error.body.message;
            }).finally(() => {
                this.isLoading = false;
            });
    }

    // Helper method to use NavigationMixin to navigate to a given record on click
    navigateToRecord(event) {
        this[NavigationMixin.Navigate]({
            type: "standard__recordPage",
            attributes: {
                recordId: event.target.dataset.recordId,
                actionName: "view"
            }
        });
    }
}

<-- BoatDataService.cls -->
public with sharing class BoatDataService {

    public static final String LENGTH_TYPE = 'Length'; 
    public static final String PRICE_TYPE = 'Price'; 
    public static final String TYPE_TYPE = 'Type'; 
	
    @AuraEnabled(cacheable=true)
    public static List<Boat__c> getBoats(String boatTypeId) {
        // Without an explicit boatTypeId, the full list is desired
        String query = 'SELECT '
                     + 'Name, Description__c, Geolocation__Latitude__s, '
                     + 'Geolocation__Longitude__s, Picture__c, Contact__r.Name, '
                     + 'BoatType__c, BoatType__r.Name, Length__c, Price__c '
                     + 'FROM Boat__c';
        if (String.isNotBlank(boatTypeId)) {
            query += ' WHERE BoatType__c = :boatTypeId';
        }
        query += ' WITH SECURITY_ENFORCED ';
        return Database.query(query);
    }
	
    @AuraEnabled(cacheable=true)
    public static List<Boat__c> getSimilarBoats(Id boatId, String similarBy) {
        List<Boat__c> similarBoats = new List<Boat__c>();
        List<Boat__c> parentBoat = [SELECT Id, Length__c, Price__c, BoatType__c, BoatType__r.Name
                                    FROM Boat__c
                                    WHERE Id = :boatId 
                                    WITH SECURITY_ENFORCED];
        if (parentBoat.isEmpty()) {
            return similarBoats;
        }
        if (similarBy == LENGTH_TYPE) {
            similarBoats = [
                SELECT Id, Contact__r.Name, Name, BoatType__c, BoatType__r.Name, Length__c, Picture__c, Price__c, Year_Built__c
                FROM Boat__c
                WHERE Id != :parentBoat.get(0).Id
                AND (Length__c >= :parentBoat.get(0).Length__c / 1.2)
                AND (Length__c <= :parentBoat.get(0).Length__c * 1.2)
                WITH SECURITY_ENFORCED
                ORDER BY Length__c, Price__c, Year_Built__c
            ];
        } else if (similarBy == PRICE_TYPE) {
            similarBoats = [
                SELECT Id, Contact__r.Name, Name, BoatType__c, BoatType__r.Name, Length__c, Picture__c, Price__c, Year_Built__c
                FROM Boat__c
                WHERE Id != :parentBoat.get(0).Id
                AND (Price__c >= :parentBoat.get(0).Price__c / 1.2)
                AND (Price__c <= :parentBoat.get(0).Price__c * 1.2)
                WITH SECURITY_ENFORCED
                ORDER BY Price__c, Length__c, Year_Built__c
            ];
        } else if (similarBy == TYPE_TYPE) {
            similarBoats = [
                SELECT Id, Contact__r.Name, Name, BoatType__c, BoatType__r.Name, Length__c, Picture__c, Price__c, Year_Built__c
                FROM Boat__c
                WHERE Id != :parentBoat.get(0).Id
                AND (BoatType__c = :parentBoat.get(0).BoatType__c)
                WITH SECURITY_ENFORCED
                ORDER BY Price__c, Length__c, Year_Built__c
            ];
        }
        return similarBoats;
    }
	
    @AuraEnabled(cacheable=true)
    public static List<BoatType__c> getBoatTypes() {
        return [SELECT Name, Id FROM BoatType__c WITH SECURITY_ENFORCED ORDER BY Name];
    }
	
    @AuraEnabled
    public static List<BoatReview__c> getAllReviews(Id boatId) {
        return [
            SELECT
                Id,
                Name,
                Comment__c,
                Rating__c,
                LastModifiedDate,
                CreatedDate,
                CreatedBy.Name,
                CreatedBy.SmallPhotoUrl,
                CreatedBy.CompanyName
            FROM
                BoatReview__c
            WHERE
                Boat__c =:boatId
            WITH SECURITY_ENFORCED
            ORDER BY
                CreatedDate DESC
        ];
    }
	
    
    // Assume this may be an API that return this data, not a SOQL query
    @AuraEnabled(cacheable=true)
    public static String getBoatsByLocation(Decimal latitude, Decimal longitude, String boatTypeId) {
        // Without an explicit boatTypeId, the full list is desired
        String query = 'SELECT Name, Geolocation__Latitude__s, Geolocation__Longitude__s FROM Boat__c ';
        if (String.isNotBlank(boatTypeId)) {
            query += 'WHERE BoatType__c = :boatTypeId ';
        }
        query += ' WITH SECURITY_ENFORCED ORDER BY DISTANCE(Geolocation__c, GEOLOCATION(:latitude, :longitude), \'mi\') LIMIT 10';
        return JSON.serialize(Database.query(query));
    }
}

 
<table style="tableCss font-family: arial, sans-serif; border-collapse: collapse; width: 100%;">
      <aura:iteration items="{!v.listValue}" var="cus" indexVar="key">
           <tr>
              <td style="border: 1px solid black; text-align: left; padding: 8px;border-color: 
                black;">
                    <input type="radio" id="Phone" name="verificationMethod" value=" 
                       {!cus.value}" checked = "false" onchange="{!c.selectMethod}"/>
                    <label class="slds-text-heading_small">&nbsp;{!cus.key}&nbsp;{!cus.value} 
                    </label>
               </td>
           </tr>
      </aura:iteration>
</table>

 
<template>
    <lightning-card>
        <h3 slot="title">
            <lightning-icon icon-name="utility:connected_apps" size="small"></lightning-icon>
            Card Title
        </h3>
        <div slot="footer">
                <lightning-badge label="Tag1"></lightning-badge>
                <lightning-badge label="Tag2"></lightning-badge>
                <lightning-badge label="Tag3"></lightning-badge>
        </div>
        <p class="slds-p-horizontal_small">Card Body (custom component)</p>
    </lightning-card>
</template>

 
And he asked me can we use Process Builder for this scenario. I said Yes. So he asked which automation tool is better to perform this scenario. I couldn't answer to this question. Can anyone tell when to use workflow rule and when to use Process Builder, I mean in which scenario should we use workflow rule and in which scenario should we use Process Builder. 

When I check for challenge I get

Challenge Not yet complete... here's what's wrong:
Please check the configuration of the custom fields on the Account object. The formulas, rollup summaries, etc. did not produce the expected outcome.

1)  Field Label - Number of deals                 
     Field Name - Number_of_deals  
     API Name - Number_of_deals__c
     Data Type - Roll-Up Summary           
     Summary Type - COUNT
     Summarized Object - Opportunity  
      Filter Criteria - Nothing

2) Field Label - Number of won deals
    Field Name - Number_of_won_deals  
    API Name - Number_of_won_deals__c
    Data Type - Roll-Up Summary
    Summary Type - COUNT
    Summarized Object - Opportunity  
     Filter CriteriaStage - EQUALS Closed Won

3) Field Label - Last won deal date
    Field Name - Last_won_deal_date  
    API Name - Last_won_deal_date__c
   Data Type - Roll-Up Summary
   Summary Type - MAX
   Summarized Object - Opportunity  
   Field to Aggregate - Opportunity: Close Date
   Filter CriteriaStage - EQUALSClosed Won

4) Field Label - Deal win percent
    Field Name - Deal_win_percent  
    API Name - Deal_win_percent__c
    Decimal Places - 0  
    IF (Number_of_deals__c > 0, (Number_of_won_deals__c /                       Number_of_deals__c), 0)
 
5) Field Label - Amount of won deals
    Field Name - Amount_of_Won_Deals  
    API Name - Amount_of_Won_Deals__c
    Data Type - Roll-Up Summary
    Summary Type - SUM
   Summarized Object - Opportunity  
    Field to AggregateOpportunity: Amount
    Filter CriteriaStage - EQUALSClosed Won

6) Field Label - Call for Service
    Field Name - Call_for_Service  
    API Name - Call_for_Service__c
    Data Type - Formula(Text) 
    IF(OR(TODAY() - 730 > Last_won_deal_date__c , TODAY() + 730        < Last_won_deal_date__c ), 'Yes','No')

i am trying to connect a dev hub in visual studio.

When I try to execute the command force:auth:web:login -d -a DevHub, I am getting an error ERROR running force:auth:web:login:  Cannot start the OAuth redirect server on port PortInUseAction. 

Try this: 
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.  
var firstnameRegex = "[a-zA-Z]";
       var firstname = component.get("v.First_Name");
       var FirstnameMatch = firstname.match(firstnameRegex);

if(FirstnameMatch == false){
            alert("Please fill in the mandatory details");
        }

I tried this but it didn't work
Visualforce page
<apex:page controller="LightningComponentRedirectClass">
    <apex:form>
        <apex:commandButton value="Continue" action="{!Continuebutton}"/>
    </apex:form>
</apex:page>
VisualForce Page controller
public class LightningComponentRedirectClass {

    public PageReference Continuebutton(){
        String name = 'Herish';
        String url ='https://mydomain.lightning.force.com/lightning/n/Component_Name?First_Name' + name;
        PageReference LC = new PageReference(url);
        return LC;
    }
}

I am able to redirect from Visualforce page to lightning component (added to lightning application which is created in Lightning app builder). But I am not able to pass parameter from Visualforce page to Lightning component. Could anyone suggest me on how to achieve this.
 
Lightning Application
<aura:application >
    <c:WrapperComponent/>
</aura:application>

Lightning component
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="person" >
    <aura:attribute type="person.WrapperClass" name="testAttribute" />
    
    <lightning:input value="{!v.testAttribute.firstName}" name="first"/>
    
    <lightning:input value="{!v.testAttribute.lastName}" name="last"/>
                    <button class="slds-button slds-button_brand" onclick="{!c.submit}">Submit</button>

</aura:component>

Controller of component
({
	submit : function(component, event, helper) {
        
		 var action = component.get("c.getSuccess");
        action.setParams({ 
            obj : component.get('v.testAttribute')
        });
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {

                alert("From server: " + response.getReturnValue());

            }
            else if (state === "INCOMPLETE") {
                alert("From server : Sorry server call is incomplete");
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    }
	
})

Ape
global with sharing class person {
   
    
    public class WrapperClass {
    @AuraEnabled
        public String firstName;
    @AuraEnabled
        Public String lastName;        
}
    @AuraEnabled
    public Static String getSuccess(WrapperClass obj){
        String r ='';
        if(obj.firstName == 'text' && obj.lastName=='text')
        { r='hi';}
        
		return r;
        
    }    

}

x class
I wold like to display this error on click the button. I want to do it this way only. Can anyone tell me how can it be done.
 
({
navigate : function(component, event, helper) {
        var navigateEvent = $A.get("e.force:navigateToComponent");
        navigateEvent.setParams({
            componentDef: "c:RegistrationFormTutorial"
        });
        navigateEvent.fire();
    }
})

I want to navigate from one lightning component to another component (RegistrationFormTutorial). I have written the above code. But I am getting error like this:


" This page has an error. You might just need to refresh it. Action failed: c:HtmlTryout$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:HtmlTryout$controller$navigate} "

Could anyone please help me on this. Thanks in advance.
({
	navigate : function(component, event, helper) {
        var navigateEvent = $A.get("e.force:navigateToComponent");
        navigateEvent.setParams({
            componentDef: "c.RegistrationFormTutorial"
        });
        navigateEvent.fire();
	}
})

I want to navigate from one lightning component to another component (RegistrationFormTutorial). I have written the above code. But I am getting error like this:


" This page has an error. You might just need to refresh it. Action failed: c:HtmlTryout$controller$navigate [Cannot read property 'setParams' of undefined] Failing descriptor: {c:HtmlTryout$controller$navigate} "

Could anyone please help me on this. Thanks in advance.
ContactComponent.cmp
<aura:component controller ="ContactController " implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name = "conList" type = "Contact"></aura:attribute>
    <lightning:input type ="text" label = "First Name" value="{!v.conList.FirstName}" ></lightning:input>
     <lightning:input type ="text" label = "Last Name" value="{!v.conList.LastName}"></lightning:input>
     <lightning:input  type ="tel" label = "Phone" value="{!v.conList.Phone}"></lightning:input>
     <lightning:input type ="email" label = "Email"  value="{!v.conList.Email}" ></lightning:input>
     <lightning:button variant="brand" label="Create" onclick="{!c.handleClick}" class="slds-m-left_x-small"></lightning:button>
</aura:component>

ContactComponentController.js

({
    handleClick : function(component, event, helper) {
        
        console.log("HIIIIIII" + conlist);
        var action = component.get("c.createContact");
        action.setParams({
           ac : component.get("v.conList")
        });
        action.setCallback(this,function(response){
            if(response.getState() == 'SUCCESS') {
            alert("Updated successfully");
            
        }
        });
    $A.enqueueAction(action);
    }
})

ContactController.apxc

public class ContactController {
    @auraEnabled
    public static void createContact( Contact c) {
      
        insert c;
    }

}

Is there any mistake in my code
Hii Team,
I want to know how can I make my customtab visible on an application.Because on the creation of object it is creating customTab and shown inside tablist(setup) but not on an application. How to do it.
Here is my code for customtab
MetadataService.CustomTab customTab = new MetadataService.CustomTab();
    customTab.FullName = objname + '__c'; 
    customTab.Motif = 'Custom70: Handsaw'; 
    customTab.CustomObject = true;    
    fields.add(customTab); 
service.createMetadata(fields); 

Its Urgent.Help me ASAP

Thanks in advance
public class Set45DayDeadlineFor1031Deal {
    // This method is called by the Set45DayDeadline process
    @InvocableMethod
    public static void SetDeadline(List<Id> X1031_DealsIds)
    {
        List<X1031_Deals__c> deals = new List<X1031_Deals__c>();
            for(Id dealId : X1031_DealsIds){
                // Query down to the children records (Property) filtered by Property Type = relinquished.  
                // Out of remaining properties grab the_ +*_earliest_*+ *_“Relinquish Final Close of Escrow” date._*
                // This date will then have 45 days added to it and will be placed in the 1031 Deal Object’s *45 Day Deadline*
                List<Property__c> properties = [SELECT Id, Name, Relinquish_Final_Close_of_Escrow__c, X1031_Deal__c
                    FROM Property__c WHERE X1031_Deal__c = :dealId AND Property_Type__c = 'Relinquished'];

                X1031_Deals__c deal = [SELECT Id, Name, X45_Day_Deadline__c, X1031_Client__c 
                    FROM X1031_Deals__c WHERE Id = :dealId][0];

                if(properties.size() > 0){
                    // A default date to change
                    Date deadline = Date.newInstance(2099, 1, 1);

                    for(Property__c prop : properties){
                        Date propDate = prop.Relinquish_Final_Close_of_Escrow__c;
                        if(propDate < deadLine){
                            deadline = propDate;
                        }
                    }
                    
                    deals.add(new X1031_Deals__c(Name='tested', X1031_Client__c=deal.X1031_Client__c));

                    deal.Id = dealId;
                    deal.X45_Day_Deadline__c = deadline.addDays(45);
                    deals.add(deal);

                    System.debug(deal.X45_Day_Deadline__c);
                    System.debug('Deals size is: ' + deals.size());
                }
            }

        if(deals.size() > 0){
            List<Database.SaveResult> results = Database.update(deals, false);
            for(Database.SaveResult result : results){
                if(!result.isSuccess()){
                    for(Database.Error err : result.getErrors()){
                        System.debug('Error: ' + err.getStatusCode() + ' ' + err.getMessage());
                    }
                }
            }
        }
    }
}

 
I have created a test class. Related list part is not covering.

On product object UP Relationship is a related list.
I have craeted a product and created UP Relationship nd inserted. how to cover if product.up relationship size>0?

batch class:

global void execute(Database.BatchableContext bc, List<Equivalent_Version__c> evList){
        Equivalent_Version__c ev = evList[0];
        List<String> mappingColorwayList = new List<String>();
        mappingColorwayList.add(ev.DOM_COLORWAY__c);
        mappingColorwayList.addAll(ev.LC_COLORWAY__c.split(','));
        // Colorway matched products.
        List<ICIX_V1__ICIX_Product__c> colorwayMatchedProductsList = new List<ICIX_V1__ICIX_Product__c>();
        Map<String, Map<String, List<String>>> equivalentUniqueVsProductVsUprMap = new Map<String, Map<String, List<String>>>();
        Map<String, ContentVersion> uniqueCvMap = new Map<String, ContentVersion>();
        Map<String, String> cpcCeritificateUniqueUprMap = new Map<String, String>();
        if(mappingColorwayList.size()>0 && !mappingColorwayList.isEmpty()){
            // Collecting all the Assortment/Solid products based on colorway code
            colorwayMatchedProductsList = [SELECT Id, ICIX_V1__Finished_Product__c, Parent_Number__c, Product_Number__c, ColorwayF__c,EquivalentUnique__c,ProductType__c,
                                           (SELECT Id,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__r WHERE ICIX_V1__Status__c = 'Active' )
                                           FROM ICIX_V1__ICIX_Product__c
                                           
                                           WHERE ColorwayF__c IN: mappingColorwayList
                                           AND EquivalentUnique__c != null
                                           AND ProductType__c IN ('ASSORTMENT','SOLID')];
            
            System.debug('======colorwayMatchedProductsList======='+colorwayMatchedProductsList);
            
            if(colorwayMatchedProductsList.size()>0 && !colorwayMatchedProductsList.isEmpty()){
                //Separating products based on parent number
                for(ICIX_V1__ICIX_Product__c product: colorwayMatchedProductsList){
                    if(product.ICIX_V1__UP_Relationship__r.size()>0){
                        for(ICIX_V1__UP_Relationship__c upr: product.ICIX_V1__UP_Relationship__r){
                            if(upr.ICIX_V1__Related_Account__c != null){
                                if(!equivalentUniqueVsProductVsUprMap.containsKey(product.EquivalentUnique__c)){
                                    equivalentUniqueVsProductVsUprMap.put(product.EquivalentUnique__c, new Map<String, List<String>>());
                                    equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).put(product.Id, new List<String>());
                                    equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                    
                                }  
                                else{
                                    if(equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).keySet().contains(product.Id)){
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                        
                                    }
                                    else{
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).put(product.Id, new List<String>());
                                        equivalentUniqueVsProductVsUprMap.get(product.EquivalentUnique__c).get(product.Id).add(upr.ICIX_V1__Related_Account__c);
                                        
                                    }
                                    
                                }
                            }
                            
                        }
                        
                    }
                    
                    
                }
                
            }
            
            System.debug('======equivalentUniqueVsProductVsUprMap======='+equivalentUniqueVsProductVsUprMap);
            
Test class:
@isTest
public class ColorwayCertificateGenerationBatch_Test {
    
    @isTest Static void test1(){
     

             
        ColorwayCertificateGenerationBatch cc=new ColorwayCertificateGenerationBatch();

        Equivalent_Version__c ev=new Equivalent_Version__c(Name='99',DOM_COLORWAY__c='229',LC_COLORWAY__c='230');
        insert ev;
        List<Equivalent_Version__c> evList=[SELECT Id, Name, DOM_COLORWAY__c, LC_COLORWAY__c FROM Equivalent_Version__c WHERE DOM_COLORWAY__c != null AND LC_COLORWAY__c != null];
    system.assertEquals(true, evList.size()>0);
        // Database.getQueryLocator(evList);
      
                List<String> mappingColorwayList = new List<String>();
                 mappingColorwayList.add(ev.DOM_COLORWAY__c);
        mappingColorwayList.addAll(ev.LC_COLORWAY__c.split(','));
        
      
        
            List<ICIX_V1__ICIX_Product__c> colorwayMatchedProductsList = new List<ICIX_V1__ICIX_Product__c>();
        Map<String, Map<String, List<String>>> equivalentUniqueVsProductVsUprMap = new Map<String, Map<String, List<String>>>();
        Map<String, ContentVersion> uniqueCvMap = new Map<String, ContentVersion>();
        Map<String, String> cpcCeritificateUniqueUprMap = new Map<String, String>();
        System.assertEquals(true, mappingColorwayList.size()>0);
        System.assertEquals(true, !mappingColorwayList.isEmpty());
        
        //creating account
    Account acc = new Account(Name = 'Name783', Type = 'Prospect', Facility_Name__c = 'Facil788', ICIX_V1__Status__c = 'Active', ICIX_V1__ICIX_ID__c = 'ICIX_480');
    Insert acc;
        List<ICIX_V1__ICIX_Product__c> productlst=new List<ICIX_V1__ICIX_Product__c>();
         ICIX_V1__ICIX_Product__c product=new ICIX_V1__ICIX_Product__c(Name='product1',ICIX_V1__Finished_Product__c=false,Parent_Number__c='C3994',Product_Number__c='C3994AS01',
         
                                                                       ProductType__c='ASSORTMENT;SOLID' ); 
       //product.EquivalentUnique__c!=null;
      
                 ICIX_V1__ICIX_Product__c product1=new ICIX_V1__ICIX_Product__c(Name='product2',ICIX_V1__Finished_Product__c=false,Parent_Number__c='C3995',Product_Number__c='C3995AS02',
         
                                                                       ProductType__c='ASSORTMENT;SOLID' ); 
       //product.EquivalentUnique__c!=null;
        productlst.add(product);
        productlst.add(product1);
        insert productlst;

        mappingColorwayList.add(product.ColorwayF__c);
       
        try{
            List<ICIX_V1__UP_Relationship__c> uplist=new List<ICIX_V1__UP_Relationship__c>();
        ICIX_V1__UP_Relationship__c up=new ICIX_V1__UP_Relationship__c(Name='C3994AS01_MVL',ICIX_V1__Related_Account__c=acc.id,ICIX_V1__Status__c='Active',
                                                                       ICIX_V1__Product__c=product.id,ICIX_V1__Type__c='Tag');
      
         ICIX_V1__UP_Relationship__c up1=new ICIX_V1__UP_Relationship__c(Name='C3994AS01',ICIX_V1__Related_Account__c=acc.id,ICIX_V1__Status__c='Active',
                                                                       ICIX_V1__Product__c=product.id,ICIX_V1__Type__c='Tag');
       
            uplist.add(up);
            uplist.add(up1);
            insert uplist;
        }
        catch(Exception e) {
            Boolean isException;
            if(e.getMessage().contains('Exception thrown for test class'))
            isException = true;
            system.assertEquals(isException, null);
        }
         colorwayMatchedProductsList = [SELECT Id, ICIX_V1__Finished_Product__c, Parent_Number__c, Product_Number__c, ColorwayF__c,EquivalentUnique__c,ProductType__c,
                                           (SELECT Id,ICIX_V1__Related_Account__c FROM ICIX_V1__UP_Relationship__r WHERE ICIX_V1__Status__c = 'Active' )
                                           FROM ICIX_V1__ICIX_Product__c
                                           
                                           WHERE ColorwayF__c IN: mappingColorwayList
                                           AND EquivalentUnique__c != null
                                           AND ProductType__c IN ('ASSORTMENT','SOLID')];
        system.assertEquals(true, productlst.size()>0);
        system.assertEquals(true, product.ICIX_V1__UP_Relationship__r.size()>0);
        
     Database.BatchableContext bc;
    cc.start(bc);
        Database.executebatch(new ColorwayCertificateGenerationBatch(),1);
        
    }

   
}
Hi guys, so the scenario for my requirement is like, I have two objects :
1. Agreement (parent object)
2. Agreement Line item (child object).

On the first screen of flow, I am creating Agreement and on the second screen after creating an agreement record I want to create the Agreement line item in which we are using the ID of the agreement created on 1st screen. What I want is to create multiple ALIs on a single screen with an option or button there which ask to create more agreement line item. 
I want a screen of this type as I shown below table
Can we achieve this type of requirement via FLOW

 
Realated AgreementFiled 1Field2 Field3Product (Lookup)
Demo Agreement-1abc xyzsdfProduct -1
Demo Agreement-1abc xyzsdfProduct -2
Demo Agreement-1abc xyzsdfProduct -3
Demo Agreement-1abc xyzsdfProduct -4
Demo Agreement-1abc xyzsdfProduct -5
     
Add More Products (Button)    
     
     
     
     
  Previous Finish









 
Hii Developers,
Please help to write test class for this part of code.
code
Income_Tax__c ITax=[select id,Rent_paid_to_landlord__c,Leave_travel_concessions_or_assistance__c,Employees_PF__c,
                            Interest_payable_paid_to_lender__c,Children_s_Education_Fee__c,PPF__c,Insurance_Premium__c,
                            NSC__c,Deduction_under_Pension_scheme__c,Housing_loan_principal_repayment__c,ELSS_Mutual_Fund__c,
                            NPS__c,Payment_for_Medical_Insurance_Premium__c,Medical_treatment_for_handicapped__c,
                            Medical_for_specified_diseases__c,Education_Loan_Interest_Repayment__c,Interest_on_loan_taken_for_house__c,
                            Donation__c,Rent_deduction_only_if_HRA_not_received__c,Saving_interest__c,Rebate_of_Rs_2000__c,RGESS__c,
                            Royalty__c,Professional_Development_Allowance__c,Car_Maintenance_Allowance__c,
                            Conveyance_Allowance__c,Helper_Allowance__c,Telephone_Internet_allowance__c,
                            Tax_by_previous_employer__c,TDS_already_deducted_by_Current_Company__c,Donation_to_Other__c
                            from Income_Tax__c where id=:tax.id];
        If(ITax.Rent_paid_to_landlord__c!=null){
            Attachment a = new Attachment(parentid=tax.id, Name = 'Rent paid to landlord.jpeg' , Body = myfile.body);
            try {insert a;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Leave_travel_concessions_or_assistance__c!=null){
            Attachment a1 = new Attachment(parentid=tax.id, Name = 'Leave travel concessions or assistance.jpeg', Body = myfile1.body);
            try {insert a1;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Interest_payable_paid_to_lender__c!=null){
            Attachment a2 = new Attachment(parentid=tax.id, Name = 'Interest payable paid to lender.jpeg' , Body = myfile2.body);
            try {insert a2;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Employees_PF__c!=null){
            Attachment a3 = new Attachment(parentid=tax.id, Name = 'Employees Provident Fund.jpeg' , Body = myfile3.body);
            try {insert a3;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Children_s_Education_Fee__c!=null){
            Attachment a4 = new Attachment(parentid=tax.id, Name = 'Children Education Fee.jpeg' , Body = myfile4.body);
            try {insert a4;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }

Please help me
Thank you.
  • July 29, 2020
  • Like
  • 0
Hi All,

I have a MultiSelectPickList field in User and Picklist in custom object. I need to compare such a way that piclist value is present in MultiSelectPickList in validation rule. I tried using INCLUDES($User.MultiSelectPickList,TEXT(Picklist)) but I got Error: Incorrect parameter type for function 'INCLUDES()'. Expected Text Literal, received Text. I analised this error and i got solution from here
https://ipfs-sec.stackexchange.cloudflare-ipfs.com/salesforce/A/question/148489.html to use triggers. 

Now my question is, is there any way to compare rather than using triggers. is there any  way to compare in  Condition Formula in validation rule 

Thanks,
sai
 
Hi,
I am trying to remove the change owner button on lead object. I removed the modify all permission and unchecked the Transfer records permission on the respective profile. Still I am not able to remove the button.User-added imageUser-added imageUser-added imagePlease help me out on this
Currently, I am using OAuth2 authorization code flow to authenticate REST services, but when I am doing request to get authorization code like this
 https://login.salesforce.com/services/oauth2/authorize?
 client_id=3MVG9IHf89I1t8hrvswazsWedXWY0i1qK20PSFaInvUgL 
 redirect_uri=https://www.mycustomerorderstatus.com/oauth2/callback& response_type=code

It requires the login & to click allow access then it redirects to my callback URL with accessCode. So I want to skip this process & auto-approve it because I am using it as background service & not interacting with user for login

How to auto approve Salesforce REST API OAuth2 authorization_code flow to not show allow pop-up.
Hi i have a question. We would like to auto delete all incomplete task in a given opportunity when 2 criteria are met. First is when there is a discharge date and second  is when there is a discharge reason.

Trial with Process Builder
The 2 crterias that we would like to be met are shown below;

Discharge Date and Reason
Hello, I have a class that is supposed to send a VF template. The debug logs are saying it is sent, but the email is not going out. Can someone help to fix my email class? What am I missing? 

CLASS
Global class LeadOwnerEmail implements Schedulable{
 Global void execute(SchedulableContext SC) {
        
List<User> uList = [select id, email from user where id in (select  ownerid from community_lead__c)];    
List<Id> listids= new List<Id>();

for(User u :uList) {
 EmailTemplate et=[Select id from EmailTemplate where name = 'LeadOwnerEmail'];
 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();     
mail.setTargetObjectId(u.id);
mail.setSenderDisplayName('Lead Ownership');
 mail.setTemplateId(et.id);
    mail.setSaveAsActivity(false);
 String[] toAddresses = new String[] {u.email};
mail.setToAddresses(toAddresses);
     system.debug('**To Addresses: ' + u.email);
//mail.setReplyTo(liaisonEmail);
       try { 
 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
           system.debug('**SENT!!!');
   return;
    } catch (Exception e) {
    System.debug(e.getMessage());
   }
    }
}
}


VF EMAIL
<messaging:emailTemplate subject="Your Team's Leads- Owner Assignments" recipientType="User" relatedToType="User">

 <messaging:htmlEmailBody >
   Hi {!RelatedTo.firstName},
  <p>The following leads have not yet been updated:</p>
   <c:leadsinfo ToID="{!RelatedTo.Id}" />
 <p>To update these leads, click on the "Lead Status" field located  in the upper right on the lead page layout.</p>
 </messaging:htmlEmailBody>

</messaging:emailTemplate>
Hello,

Before starting, I know about DML operations and the order they should be performed in for test cases. Please do not comment on that. These test cases succeed and have been succeeding in partial and production for over 2 years. 

We recently enabled the Office 365 Outlook Configuration and we started getting test cases failing in production.

Here is the error that we see:
first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Case, original object: S2XUserMap: []

We saw this was once an issue in Winter'18 but has (apparently) been fixed.

https://trailblazer.salesforce.com/issues_view?id=a1p3A0000008gVyQAI

I think my next step is to go through all of the test cases and use a user and profile that is not mapped in the Outlook Office 365 config. These would be used in just the test case execution. 

Our current test cases were written by persona/profile so that we would test specific areas that our code needed to run against. We do create users and use System.runAs() for that test. 

Does anyone else have this happening to them also? Or did this happen to anyone else?