• Soundar Raj Ponpandi
  • NEWBIE
  • 390 Points
  • Member since 2017
  • Salesforce Developer
  • Smaartt Dubai

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 60
    Questions
  • 89
    Replies
Hi,
Kindly anyone can help on below questions for PD:

Thanks in advance.


1. Create a visualforce page for opportunities that allows user to save or merge the current record. What approach -
A.  Custom Controller
B.  Custom Contoller extension
C.  Visualforce Java Script
D.  Standard Controller Methods.    

2. A developer must build an application that tracks which accounts have purchased specific pieces of equip Products. Each Account could purchase many pieces of equipment.

How should the developer track that an account has purchased a piece of equipment?
A.  Use the Asset object
B.  Use a custom object
C.  Use a Master-Detail on Product to Account
D.  Use a lookup on Account to Product    

 
  • July 05, 2020
  • Like
  • 0
Hello all,

We would like to change the subject ""First payment reminder" " as mentioned in below sample visulaforce code, based on the some condtions.
That means, If i send first reminder email then i am going to update the field "Total remider sent" value to 1,
Then later after checking other due dates conditions, ww would like to send another email but with different Subject i.e ". "Second payment reminder" and again update Total remider sent" value to 2.
can you please help how to handle such situation, This will help me to reuse same template for all the reminder;s, Invoice information will be picked up on run time, so no issues with that.


My Visualforce working code is - 

<messaging:emailTemplate subject="First payment reminder" recipientType="Contact" relatedToType="Account">

<!-- <messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody> -->

<messaging:htmlEmailBody >
    <STYLE type="text/css">
        TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
        TD  {font-size: 11px; font-face: verdana }
        TABLE {border: solid #CCCCCC; border-width: 1}
        TR {border: solid #CCCCCC; border-width: 1}
     </STYLE>
     <font face="arial" size="2">

<font size="2" face="Lucida Sans Unicode" > Dear  {!relatedTo.Name}, </font><br/>
<br/>

<font size="2" face="Lucida Sans Unicode" >Our financial records show that -- subscription for the total amount {!relatedTo.CurrencyIsoCode}&nbsp;{!relatedTo.Total_Outstanding_Amount__c} </font><br/>
<br/>


 
<br/>
        <table border="0" > 
            <tr>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Invoice Number   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Payment Due Date   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Amount Due   ;</font><br/></th>
                <th align="right"><font size="2" face="Lucida Sans Unicode" >Currency   ;</font><br/></th>
                
            </tr>
            
            <apex:repeat var="cx" value="{!relatedTo.Invoices__r}" >

               <tr>
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >{!cx.Invoice_Number__c}&nbsp;</font></td>
                        
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >
                            <apex:outputText value="{0,date,dd'/'MMM'/'yyyy}">
                                <apex:param value="{!cx.Transaction_Due_Date_del__c}" /> 
                            </apex:outputText>&nbsp;</font>
                        </td>


                        <td align="right"><font size="2" face="Lucida Sans Unicode">&nbsp;
                            <apex:outputText style="float:right" value="{0, number, ###,##0.00}">
                                <apex:param value="{!cx.Outstanding_Amount_FC__c}"/>
                            </apex:outputText>&nbsp;</font>
                        </td>
                        
                        <td align="right"><font size="2" face="Lucida Sans Unicode" >{!cx.Currency__c}&nbsp;</font></td>
                                                                        
               </tr>
                                   
            </apex:repeat>
        </table>  
     </font>
                    
<br/>

<font size="2" face="Lucida Sans Unicode" >Our bank details:</font><br/>
<font size="2" face="Lucida Sans Unicode" >Payment reference: {!relatedTo.Exact_Online_Account_ID__c} </font><br/>
<font size="2" face="Lucida Sans Unicode" >Please do not hesitate to contact us with questions. Thank you in advance for your cooperation. </font><br/>

<br/>
<br/>
<br/>  
                
<font size="2" face="Lucida Sans Unicode" >Best regards,</font><br/>
<font size="2" face="Lucida Sans Unicode" >Collection department</font><br/>
<font size="2" face="Lucida Sans Unicode" >BV Amsterdam, the Netherlands</font><br/>
                
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Hi,

I have 2 scenarios in custom object

1. If it's old user system should get update 

2. If it's a new user system get insert with list of users.

i have done with single record and getting confused for bulk records.

Can you please refer my coding and advise me how can i create for bulk records for update existing records.

If you are suggesting with MAP it's really appriciate.

Apex Controller
/*Upadte Existing Record*/
            set<id> ExUser = new set<id>();
            set<id> newUser = new set<id>();
            string newRole;
            string newAccess;
            List<GD_Quote_Team__c> ExMembers = [select ID,GD_User__c,GD_User__r.Name from GD_Quote_Team__c where GD_Quotes__c =: quoteId];
            
            for(GD_Quote_Team__c ex_mem : ExMembers){
               GD_Quote_Team__c qtm = new GD_Quote_Team__c();
                qtm.Id = ex_mem.Id;
                qtm.GD_User__c = ex_mem.GD_User__c;
                ExUser.add(qtm.GD_User__c);
               
            }
            
            for(GD_Quote_Team__c new_mem : qtTeamList){
                newUser.add(new_mem.GD_User__c);
                newRole = new_mem.GD_Team_Role__c;
                newAccess = new_mem.GD_Quote_Access__c;
                
            }
            List<GD_Quote_Team__c> updtMembers = new List<GD_Quote_Team__c>();
            if(ExUser == newUser){
                GD_Quote_Team__c ExMembers1 = [select ID,GD_User__c,GD_User__r.Name,GD_Team_Role__c,GD_Quote_Access__c from GD_Quote_Team__c where GD_Quotes__c =: quoteId and GD_User__c =: ExUser];
                GD_Quote_Team__c NwMembers1 = [select ID,GD_User__c,GD_User__r.Name,GD_Team_Role__c,GD_Quote_Access__c from GD_Quote_Team__c where GD_Quotes__c =: quoteId and GD_User__c =: newUser]; 
                GD_Quote_Team__c qtm1 = new GD_Quote_Team__c();
                qtm1.Id = ExMembers1.Id;
                qtm1.GD_User__c = NwMembers1.GD_User__c;
                qtm1.GD_Team_Role__c = newRole;
                qtm1.GD_Quote_Access__c = newAccess;
                updtMembers.add(qtm1);  
                update updtMembers;
            } else if(ExUser != newUser){
                if(qtTeamList.size()>0){upsert qtTeamList;}
            }

Thanks In Advance,
Soundar.
HI,

I would like to display a picklist value from record.

1. I am using one custom object it's called "GD_Offer__c ". I want to display a field as  a picklist with reference of "GD_Offer__c" records.

2. For example i have 3 following records in this "GD_Offer__c" table, I need to display those records in picklist value.

       A. Offer A
       B. Offer B
       C. Offer C


I wrote coding for this functionality, I am not sure where i did a mistake. Can you please guide me where i did a mistake and what are all the changes i need to do to achieve mentioned functionality.


Apex Class Method 
@AuraEnabled 
     public static Map<String, String> getOffers(){
        system.debug('Entered into the Get Offers ********'); 
        Map<String, String> options = new Map<String, String>();
        Schema.DescribeFieldResult fieldResult = GD_Offers__c.Name.getDescribe();
         system.debug('fieldResult | ' + fieldResult);
        List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues();
         system.debug('pList ' + pList);
        for (Schema.PicklistEntry p : pList) {
            options.put(p.getValue(), p.getLabel());
        }
        system.debug('Options |' + options);
        return options;
    }

Component
 
<aura:attribute name="offerMap" type="Map"/>

<table>
<tr>
<td>
                            <lightning:recordEditForm aura:id="form" objectApiName="GD_Quote_Line_Items__c" >
                               
                                <div class="form-group">
                                    <lightning:select aura:id="industryPicklist" value="{!v.lineItem.GD_Offers__c}" onchange="{!c.handleCompanyOnChange}">
                                        <option value="">--None--</option>
                                        <aura:iteration items="{!v.offerMap}" var="ind" indexVar="key">
                                            <option text="{!ind.value}" value="{!ind.key}" selected="{!ind.key==v.lineItem.GD_Offers__c}" />
                                        </aura:iteration>
                                    </lightning:select>
                                </div>
                            </lightning:recordEditForm>
                        </td>
</tr>
</table>

Controller.JS
doInit: function(component, event, helper) {
        helper.getOfferPicklist(component, event);
    },

Helper.JS
getOfferPicklist: function(component, event) {
        alert('Entered Offer Picklist');
        var action = component.get("c.getOffers");
        action.setCallback(this, function(response) {
            var state = response.getState();
            alert('State = ' + state);
            if (state === "SUCCESS") {
                var result = response.getReturnValue();
                var offerMap = [];
                for(var key in result){
                    offerMap.push({key: key, value: result[key]});
                }
                component.set("v.offerMap", offerMap);
            }
        });
        $A.enqueueAction(action);
    },


Thanks In Advance,
Soundar.
Thanskn
Hi,

I am sharing Opportunity record from Quote team members. In This scenario i would like to add one more functionality as mentioned below.

1. As of now this functionality is working for add a new team members.

2. But if already this record has shared to User A, Again i am sharing to same User A. At that time system should update a Old record with latest update (Without Creating a new record).

3. I am little confused to launch this functionality.

Can you please check my code and let me know where i need to make a changes to achieve metioned functionality.


Code For Review
 
public with sharing class GD_CreateQuoteTeam { 
    @AuraEnabled
    public static void saveQuoteTeam(List<GD_Quote_Team__c> teamList, string quoteId){
        try{
            list<GD_Quote_Team__c> qtTeamList = new list<GD_Quote_Team__c>();
            list<opportunityShare> readShareList = new list<opportunityShare>();
            list<opportunityShare> editShareList = new list<opportunityShare>();    
            
            GD_Quote__c qt = [select id,GD_Opportunity__c from GD_Quote__c where id =: quoteId];
            id oppId = qt.GD_Opportunity__c;
            system.debug('Opportunity Id '+ oppId);
            for(GD_Quote_Team__c team : teamList){
                team.GD_Quotes__c = quoteId;
                qtTeamList.add(team);
            }
            if(qtTeamList.size()>0){Insert qtTeamList;}
            
            for(gd_quote_Team__c qTeam : qtTeamList){
                if(qTeam.GD_Quote_Access__c == 'Read Only'){
                    system.debug('Enter Into the Read only = ' + qTeam.GD_Quote_Access__c);
                    opportunityShare shareRecord = new opportunityShare();
                    shareRecord.OpportunityAccessLevel = 'Read';
                    shareRecord.UserOrGroupId = qTeam.GD_user__c;
                    shareRecord.OpportunityId = oppId;
                    readShareList.add(shareRecord);
                }    
            }
            if(readShareList.size()>0){insert readShareList;system.debug('Read Access Provided');}        
            
            for(gd_quote_Team__c qTeam : qtTeamList){  
                if(qTeam.GD_Quote_Access__c == 'Read/write'){
                    system.debug('Access |' + qTeam.GD_Quote_Access__c);
                    opportunityShare shareRecord = new opportunityShare();
                    shareRecord.OpportunityAccessLevel = 'edit';
                    shareRecord.UserOrGroupId = qTeam.GD_user__c;
                    shareRecord.OpportunityId = oppId;
                    editShareList.add(shareRecord);
                } 
            }
            if(editShareList.size()>0){insert editShareList;system.debug('Edit Access Provided');} 
        }catch(Exception e){system.debug('Exception -' + e);}
        
    }
    
}


Thanks in advance,
Soundar Rajan P.
 
Hi,

I tried in many way but lightning quick action is not possible in lightnig related list button.

I found few ideas also
https://success.salesforce.com/ideaView?id=0873A0000003TXFQA2

But i am expecting an alternate way to implement this functionality.

Can anyone please help me to achieve this functionality .


Regards,
Soundar.
Hi,

I am trying to share a custom quote record to user's. But i am facing following error.
This Record is having "Control By Parent" access.
Even i tried with opportunity as a parentId.
DEBUG|Exception -System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Parent ID: id value of incorrect type: a0g0C000001NvFxQAK: [ParentId]

Can you please tell me where i did  a mistake and how can i achieve it in a success way.
 
public class GD_CreateQuoteTeam { 
    @AuraEnabled
    public static void saveQuoteTeam(List<GD_Quote_Team__c> teamList, string quoteId){
        try{
        list<GD_Quote_Team__c> qtTeamList = new list<GD_Quote_Team__c>();
        list<GD_Quote_Team__Share> readShareList = new list<GD_Quote_Team__Share>();
        list<GD_Quote_Team__Share> editShareList = new list<GD_Quote_Team__Share>();
        for(GD_Quote_Team__c team : teamList){
            team.GD_Quotes__c = quoteId;
            qtTeamList.add(team);
        }
        Insert qtTeamList;
        /*Share Record - Read Only*/
        for(gd_quote_Team__c qTeam : [select id,name,GD_user__c from gd_quote_Team__c where GD_Quotes__c =: quoteId and GD_Quote_access__c = 'Read Only']){
            GD_Quote_Team__Share shareRecord = new GD_Quote_Team__Share();
                shareRecord.AccessLevel = 'Read';
                shareRecord.UserOrGroupId = qTeam.GD_user__c;
                shareRecord.ParentId = quoteId;
                readShareList.add(shareRecord);
        }
        if(readShareList.size()>0){insert readShareList;}        
        /*Share Record - Read/Write*/
        for(gd_quote_Team__c qTeam : [select id,name,GD_user__c from gd_quote_Team__c where GD_Quotes__c =: quoteId and GD_Quote_access__c = 'Read/write']){
            GD_Quote_Team__Share shareRecord = new GD_Quote_Team__Share();
                shareRecord.AccessLevel = 'edit';
                shareRecord.UserOrGroupId = qTeam.GD_user__c;
                shareRecord.ParentId = quoteId;
                editShareList.add(shareRecord);
        }
        if(editShareList.size()>0){insert editShareList;} 
            }catch(Exception e){system.debug('Exception -' + e);}
        
    }
    
}

Many Thanks in Advance.
Soundar Rajan P.
Hi ,

below code getting Error State while saving the record so i couldn't navigate to recently created record page.
 
getSave : function (component, event, helper) {
        alert('Current Record Id |' + component.get("v.recordId"));
        var action = component.get("c.GD_newQuoteVersion");
        var toastEvent = $A.get("e.force:showToast");
        action.setParams({
            //"quote":component.get("v.quote"),
            quoteId: component.get("v.recordId")
        });
        
        action.setCallback(this,function(result){
            var state = result.getState();
            alert('state ' + state);
            /*if (state == "SUCCESS") {
                var res = result.getReturnValue();
                alert('INside of success ' + res);
                component.set("v.returnId",res);
            }*/
            var newQtId = result.getReturnValue();
            console.log('Return Value is:' + JSON.stringify(result.getReturnValue()));
            alert('New Quote Id - ' + JSON.stringify(result.getReturnValue()));
            //component.set("v.returnId",data.getReturnValue());
            /*Toast Event*/
            toastEvent.setParams({
                title: "Success!",
                message: "Quote is created successfully!",
                type: "success"
            });
            toastEvent.fire();
            /*Navigation*/
            var recId = component.get("v.recordId");
            var sObectEvent = $A.get("e.force:navigateToSObject");
            sObectEvent .setParams({
                "recordId": recId,
                "slideDevName": "detail"
            });
            sObectEvent.fire();
        });
        $A.enqueueAction(action);  
    }

Can anyone please tell me where i did mistake ? 

Hearty thanks in advance.

Regards,
Soundar.
Hi,

How to cover a test class for followig apex class.
 
Apex Class
__________________________

public without sharing class GD_RemoveProcessRecords {

    public static void removeProcess(List<Approval.ProcessWorkitemRequest> requests){
         Approval.process(requests, true);
    }
}

Test Class
 
@isTest
public class GD_RemoveProcessRecordsTest {
    
    static testMethod void removeProcessTestMethod() {
        
        Account acc1 = GD_TestDataFactory.createCustomer('Acc1','Customer');
        acc1.GD_Pharma_Location__c = 'Dubai';
        acc1.GD_Pharma_Account__c = true;
        Insert acc1;

        
        GD_Order__c ord = new GD_Order__c(GD_Account__c = acc1.id);
        insert ord;
        
        Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
        req.setComments('Submitting request for approval.');
        req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
        req.setObjectId(ord.Id);
        Approval.ProcessResult result =  Approval.process(req);
        
        test.startTest();
        //GD_RemoveProcessRecords.removeProcess(new List<Approval.ProcessWorkitemRequest>{req});
        test.stopTest();
    }
    
}

Thanks in advance,
Soundar.​​​​​​​
Hi,

Can anyone please help to cover a test class for following simple class.
 
public without sharing class GD_CartShare {

    public static void shareCartRecordWhilePlacingOrder(List<GD_Cart__c> cartItems,List<User> approverUserList ){
       
    }
    
    public static void deleteCartItems(List<GD_Cart__c> toBeDeletedCart){
        Delete toBeDeletedCart;
    }
    
}

Regards,
Soundar.
HI,

Can anyone please cover a test class for following code ?
 
public without sharing class GD_RemoveProcessRecords {

    public static void removeProcess(List<Approval.ProcessWorkitemRequest> requests){
         Approval.process(requests, true);
    }
}


Regards,
Soundar.
 
Hi,

Email notification is not sending after sharing the record. Can anyone please check and where i did a mistake.
 
public static void GD_shareOrderWithStoreUser(Map<Id,GD_Order__c> newMap, Map<Id,GD_Order__c> oldMap){
        
        List<GD_Order__c> ordersToShare = new List<GD_Order__c>();
        
        for( GD_Order__c order : newMap.values()) {
            if(order.GD_Type__c == 'Online Order' && 
               order.GD_Status__c != oldMap.get(order.Id).GD_Status__c  
               && order.GD_Status__c == 'Accepted' && order.GD_Sales_Rep__c != null ){
                   ordersToShare.add(order);
                   system.debug('*Order to share ***' + order.name);
               }
        }
        
        if(ordersToShare.size() > 0){
            List<GD_Order__Share> orderShareList = new List<GD_Order__Share>();

            Map<String,Group> groupIdByName = new Map<String,Group>();
            Map<String,List<Id>> usersByGroup = new Map<String,List<Id>>();
            
            for(Group grp : [SELECT Id,DeveloperNAME,(SELECT Id,UserOrGroupId FROM GroupMembers) FROM Group 
                             WHERE  DeveloperNAME = 'Pharma_Store_Dubai' OR DeveloperNAME = 'Pharma_Store_Abu_Dhabi']){	
                                 if(grp.DeveloperNAME ==  'Pharma_Store_Dubai'){
                                     groupIdByName.put('Dubai', grp);
                                 }
                                 if(grp.DeveloperNAME ==  'Pharma_Store_Abu_Dhabi'){
                                     groupIdByName.put('Abu Dhabi', grp);
                                 }
                                 for(GroupMember gm : grp.GroupMembers){
                                     if(grp.DeveloperNAME ==  'Pharma_Store_Dubai'){
                                         if(usersByGroup.containsKey('Dubai')){
                                             usersByGroup.get('Dubai').add(gm.UserOrGroupId);
                                         }else{
                                             usersByGroup.put('Dubai',new List<Id>{gm.UserOrGroupId});
                                         }
                                     }else if(grp.DeveloperNAME ==  'Pharma_Store_Abu_Dhabi'){
                                         if(usersByGroup.containsKey('Abu Dhabi')){
                                             usersByGroup.get('Abu Dhabi').add(gm.UserOrGroupId);
                                         }else{
                                             usersByGroup.put('Abu Dhabi',new List<Id>{gm.UserOrGroupId});
                                         }
                                     }
                                 }
                             }
            if(groupIdByName.size() > 0){
                List<EmailTemplate> templateList = [SELECT Id,Body FROM EmailTemplate 
                                                    WHERE DeveloperName ='GD_Email_Notification_to_Approvers'];
                List<Messaging.SingleEmailMessage> sendEmailNotification = new List<Messaging.SingleEmailMessage>();
                
                for( GD_Order__c order : ordersToShare) {
                    if(groupIdByName.containsKey(order.GD_Pharma_Location__c)){
                        GD_Order__Share shareRecord = new GD_Order__Share();
                        shareRecord.AccessLevel = 'Edit';
                        shareRecord.UserOrGroupId = groupIdByName.get(order.GD_Pharma_Location__c).Id;
                        shareRecord.ParentId = order.Id;
                        system.debug('shareRecord '+shareRecord);
                        orderShareList.add(shareRecord);
                        if(templateList.size() > 0){
                            if(usersByGroup.containsKey(order.GD_Pharma_Location__c)){
                                for(Id storeUserId : usersByGroup.get(order.GD_Pharma_Location__c)){
                                    system.debug('Store User Email |' + storeUserId);
                                    Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(templateList.get(0).Id, storeUserId, order.Id);
                                    String emailSubject = mail.getSubject();
                                    String emailTextBody = mail.getPlainTextBody();
                                    mail.setSubject(emailSubject);
                                    mail.setPlainTextBody(emailTextBody);
                                    mail.setSaveAsActivity(false);
                                    mail.setTargetObjectId(storeUserId); 
                                    sendEmailNotification.add(mail);
                                }
                            }
                        }
                    }
                } 
                if(orderShareList.size () > 0){
                    Insert orderShareList;
                }
                if(sendEmailNotification.size() > 0){
                    system.debug('sendEmailNotification.size()' + sendEmailNotification.size());
                    List<Messaging.SendEmailResult> results = Messaging.sendEmail(sendEmailNotification);
                }
                
            }
        }
    }

Regards,
Soundar.
Hi,

I am sending an email with Custom Email template. But target object id is not accepted custom object. It's always accepting user, lead and few standard object.

How can i map my custom email template with related object fields.
 
GD_Order__c ordEmail = [select id,name,GD_Account__c,GD_Account_Name_Formula__c, GD_Sales_Rep__c, GD_Sales_Rep_Name_Formula__c,GD_Sales_Manger_Name_Formula__c,GD_Sales_Manager__c,GD_No_of_Ordered_Items__c,GD_Pharmacy_Location__c from GD_Order__c where id =:ordId];
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                EmailTemplate emailTemplate = [Select Id,name,Subject,Description,HtmlValue,DeveloperName,Body from EmailTemplate where name = 'Sales Order Sharing Records Email Template - Dubai'];
                system.debug('emailTemplate' + emailTemplate.name);
                mail.setTemplateID(emailTemplate.Id); 
                //mail.setTargetObjectId(ordEmail.Id);
                mail.setSaveAsActivity(false);

Can anyone resolve my queries.

Regards,
Soundar.
Hi I covered a test class for 62%, Can anyone please explain what is the issue on this ??

Apex class
 
/*
Description : Generate PDF in Sales order Details Page.
*/


public with sharing class GD_SalesOrderPrintableView {
    
    public string so_Id = apexpages.currentpage().getparameters().get('id');
    public List<GD_Order_Line_Item__c> accList{get;set;}
    public List<GD_Address__c> addList{get;set;}
    
    public GD_SalesOrderPrintableView (ApexPages.StandardController controller){
        accList = [select id,name ,GD_Unit_Price__c,GD_Total_Amount_Formula__c, GD_Quantity__c,GD_Item__r.GD_Item_Code__c, GD_Vat__c, GD_Discount__c,GD_Retail_Price__c from GD_Order_Line_Item__c where GD_Sales_Order__c =: so_Id];
        GD_Order__c so = [select id,name,GD_Account__c from GD_Order__c where id =:so_Id]; 
        system.debug('Sales Order +++ ' + so.name);
        string acc = so.GD_Account__c;
        system.debug('Account Name ++ ' + acc);
        addList = [select id,name,GD_Type__c,GD_Account__c,GD_Address_1__c,GD_Address_2__c,GD_Address_3__c from GD_Address__c where GD_Account__c =:acc and  GD_Type__c = 'BILL_TO' Limit 1];
    }
}

Test Class
 
@isTEst
public class GD_SalesOrderPrintableViewTest {

    
    public static testmethod void testData(){
        
        Account acc = GD_TestDataFactory.createCustomer('Acc1','Customer');
        insert acc;
        
        Account acc1 = GD_TestDataFactory.createCustomer('Acc1','Customer');
        insert acc1;
        
        GD_Address__c address = new GD_Address__c(GD_account__c = acc.id, GD_Address_1__c = 'address 1', GD_Address_2__c = 'address 2', GD_Address_3__c = 'address 3');
        address.GD_Type__c = 'BILL_TO';
        address.GD_Account__c = acc1.id;
        insert address;
        
        GD_Order__c ord = new GD_Order__c(GD_Account__c = acc.id);
        insert ord;
        
        GD_Inventory_Organization__c inOrg = new GD_Inventory_Organization__c(Name = 'Test'); 
        insert inOrg;
        
        GD_Item_Master__c imas = new GD_Item_Master__c(GD_Item_Code__c= '001122', GD_Unit_Price__c = 1, GD_Inventory__c = inOrg.id);
        insert imas;
        
        GD_Order_Line_Item__c oli = new GD_Order_Line_Item__c(name = 'test',GD_Unit_Price__c = 10, GD_Quantity__c = 2,GD_Item__c = imas.id, GD_Vat__c = 2);
        oli.GD_Sales_Order__c = ord.id;
        oli.GD_Retail_Price__c = 1;
        insert oli;
        
        
        ApexPages.StandardController sc = new ApexPages.standardController(oli);
        GD_SalesOrderPrintableView controller = new GD_SalesOrderPrintableView(sc);
        
        ApexPages.StandardController sc1 = new ApexPages.standardController(imas);
         GD_SalesOrderPrintableView controller1 = new GD_SalesOrderPrintableView(sc1);
        
        
    }
    
}

Thanks in advance,
Soundar.​​​​​​​
HI ,

I am facing the following error , can anyone please help me to resolve this error.
 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Sales Order” process failed. Give your Salesforce admin these details. <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.: []

My test cass is following here 
 
@isTEst
public class GD_SalesOrderPrintableViewTest {

    
    public static testmethod void testData(){
        
        Account acc = GD_TestDataFactory.createCustomer('Acc1','Customer');
        insert acc;
        
        GD_Address__c address = new GD_Address__c(GD_account__c = acc.id, GD_Address_1__c = 'address 1', GD_Address_2__c = 'address 2', GD_Address_3__c = 'address 3');
        insert address;
        
        GD_Order__c ord = new GD_Order__c(GD_Account__c = acc.id);
        insert ord;
        
        GD_Inventory_Organization__c inOrg = new GD_Inventory_Organization__c(Name = 'Test'); 
        insert inOrg;
        
        GD_Item_Master__c imas = new GD_Item_Master__c(GD_Item_Code__c= '001122', GD_Unit_Price__c = 1, GD_Inventory__c = inOrg.id);
        insert imas;
        
        GD_Order_Line_Item__c oli = new GD_Order_Line_Item__c(name = 'test',GD_Unit_Price__c = 10, GD_Quantity__c = 2,GD_Item__c = imas.id, GD_Vat__c = 2);
        oli.GD_Sales_Order__c = ord.id;
        insert oli;
        
        
        
        ApexPages.StandardController sc = new ApexPages.standardController(oli);
        GD_SalesOrderPrintableView controller = new GD_SalesOrderPrintableView(sc); 
        
    }
    
}

my class is following here 
 
/*
Description : Generate PDF in Sales order Details Page.
*/


public with sharing class GD_SalesOrderPrintableView {
    
    public string so_Id = apexpages.currentpage().getparameters().get('id');
    public List<GD_Order_Line_Item__c> accList{get;set;}
    public List<GD_Address__c> addList{get;set;}
    set<id> accId = New set<id>();
    public GD_SalesOrderPrintableView (ApexPages.StandardController controller){
        accList = [select id,name ,GD_Unit_Price__c,GD_Total_Amount_Formula__c, GD_Quantity__c,GD_Item__r.GD_Item_Code__c, GD_Vat__c, GD_Discount__c from GD_Order_Line_Item__c where GD_Sales_Order__c =: so_Id];
        GD_Order__c so = [select id,name,GD_Account__c from GD_Order__c where id =:so_Id]; 
        string acc = so.GD_Account__c;
        system.debug('Account Name ++ ' + acc);
        addList = [select id,name,GD_Type__c,GD_Account__c,GD_Address_1__c,GD_Address_2__c,GD_Address_3__c from GD_Address__c where GD_Account__c =:acc and  GD_Type__c = 'BILL_TO' Limit 1];
    }
}

Thanks in advance,
Regards,
Soundar.​​​​​​​
Hi,

Can you cover a test class for this sample class
 
/*
Description : Generate PDF in Sales order Details Page.
*/


public with sharing class GD_SalesOrderPrintableView {
    
    public string so_Id = apexpages.currentpage().getparameters().get('id');
    public List<GD_Order_Line_Item__c> accList{get;set;}
    public List<GD_Address__c> addList{get;set;}
    set<id> accId = New set<id>();
    public GD_SalesOrderPrintableView (ApexPages.StandardController controller){
        accList = [select id,name ,GD_Unit_Price__c,GD_Total_Amount_Formula__c, GD_Quantity__c,GD_Item__r.name, GD_Vat__c, GD_Discount__c from GD_Order_Line_Item__c where GD_Sales_Order__c =: so_Id];
        GD_Order__c so = [select id,name from GD_Order__c where id =:so_Id]; 
        string acc = so.GD_Account__c;
        system.debug('Account Name ++ ' + acc);
        addList = [select id,name,GD_Type__c from GD_Address__c where id =:acc and  GD_Type__c = 'BILL_TO' Limit 1];
    }
}

Regards,
Soundar.​​​​​​​
Hi,

I am facing one challanging while launching a community portal.

1. Each and avery functionality is working fine.
2. But here we are facing one challanging security functionality.
3. I closed all tabs from the browser, When i open few minutes later this page is redirecting me directly into the application without giving user name and password.
4.I know very well it's happening because of cookies.
5. But it's a high rated of Pharma Application, It should show the user name and password  page again.
6. Should i change anything in the browser ? or in the community portal.


Can anyone please resolve my query.

Thansk in advance.
Regards,
Soundar.
Hi ,

Can anyone helps to cover a test class for this class 
public class GD_ProductSearchController {
    public static ApexPages.StandardSetController ssc;
    public static Map<Id,GD_CartProductsWrapper> mapOfProduct = new Map<Id,GD_CartProductsWrapper>();
    //    public static final String  priceListName = 'RPL01';
    public static List<GD_Cart__c> cartListToReturn = new List<GD_Cart__c>();
    @AuraEnabled
    public static InitData getDataInit(){
        InitData data = new InitData();
        data.cartProducts = getExistingProductsInCart();
        data.assignedInventories = getInventoryOrgDetails();
        return data;
    }
    
    @AuraEnabled
    public static List<GD_Cart__c> getProductsToDisplay(String pageSize,String pageNumber,String productSearch,String inventoryOrgId){
        try{
            mapOfProduct = new Map<Id,GD_CartProductsWrapper>();
            cartListToReturn = new List<GD_Cart__c>();
            system.debug('Inventory '+inventoryOrgId);
            List<User> loggedInUser = new List<User>();
            loggedInUser = [SELECT Id,Name,Contact.AccountId FROM User WHERE Id=:userInfo.getUserId()];
            Account acc = [SELECT Id,GD_Customer_Class__c,GD_Status__c,GD_Product_List__c,GD_Price_List__c FROM Account WHERE Id=:loggedInUser.get(0).Contact.AccountId];
            // AND GD_Status__c = 'Active' AND GD_Product_List__c != null
            if(acc.GD_Status__c != 'Active'){
                throw new AuraHandledException('Your account is not Active. Please contact sales rep to activate your account.');    
            }
            if(acc.GD_Product_List__c == null){
                throw new AuraHandledException('Please contact your sales rep with error message - Product list not assigned to customer.');    
            }
            if(acc.GD_Price_List__c == null){
                throw new AuraHandledException('Please contact your sales rep with error message - Price list not assigned to customer.');    
            }
            
            system.debug('GD_Product_List__c '+acc.GD_Product_List__c);
            if(acc.GD_Price_List__c != null){
                String priceListId = acc.GD_Price_List__c; 
                Set<Id> portalItemIds = new Set<Id>();
                // GD_Inventory_Organization__c=:inventoryOrgId AND
                for(GD_Portal_Products__c product : [SELECT Id,Name,GD_Item__c FROM GD_Portal_Products__c WHERE GD_Product_List__c=:acc.GD_Product_List__c]){
                    portalItemIds.add(product.GD_Item__c);
                }
                system.debug('---> portalItemIds '+portalItemIds);
                if(portalItemIds.size() > 0){
                    String query = 'SELECT Id,Name,GD_Item_Description__c,GD_Item__c,GD_Price_List__c,GD_Item__r.GD_Inventory__c, ';
                    query += ' GD_Unit_Price__c,GD_UOM__c,GD_Code_UOM_Formula__c FROM GD_Price_List_Entry__c ';
                    query += ' WHERE GD_Price_List__c = :priceListId  AND GD_Item__r.GD_Inventory__c = :inventoryOrgId';
                    query += ' AND GD_Item__r.GD_Segment_3__c = \'A\' ';
                    query += ' AND GD_Item__c IN :portalItemIds ';
                    system.debug('productSearch '+productSearch);
                    if(productSearch != ''){
                        String searchTerm = '%'+String.escapeSingleQuotes(productSearch) +'%';  // assign the search term to a variable
                        query += ' AND GD_Item_Description__c LIKE :searchTerm';
                    }
                    //        query += ' AND GD_Unit_Price__c > 0  ';  
                    query += ' ORDER BY GD_Item_Description__c ';
                    system.debug('pageSize '+pageSize);
                    system.debug('pageNumber '+pageNumber);
                    system.debug('query '+query);
                    
                    ssc = new ApexPages.StandardSetController( Database.getQueryLocator( query ) );
                    system.debug('ssc '+ssc);
                    
                    //set page size
                    ssc.setpagesize(Integer.valueOf(pageSize));
                    //set page number 
                    ssc.setPageNumber(Integer.valueOf(pageNumber));
                    system.debug(' Set Page number');
                    //      accountList =  (List<Account>) ssc.getRecords();
                    system.debug(' Adding account list');
                    List<GD_Price_List_Entry__c> priceList = new List<GD_Price_List_Entry__c>();
                    priceList =  (List<GD_Price_List_Entry__c>) ssc.getRecords();
                    system.debug('---> priceList '+priceList);
                    system.debug('ssc.getHasNext() '+ssc.getHasNext());
                    system.debug('ssc.getHasPrevious()'+ssc.getHasPrevious());
                    //system.debug();
                    system.debug('ssc.getRecords() '+ssc.getRecords());
                    system.debug('priceList '+priceList);
                    List<GD_CartProductsWrapper> cartProducts = new  List<GD_CartProductsWrapper>();
                    
                    List<GD_CartProductsWrapper> listOfProduct = new List<GD_CartProductsWrapper>();
                    List<GD_Order_Line_Item__c> orderLineItem = new List<GD_Order_Line_Item__c>();
                    Map<Id,List<String>> uomList = new Map<Id,List<String>>();
                    for(GD_Price_List_Entry__c p : priceList){
                        populateWrapper(p,inventoryOrgId);
                    }
                }
            }
            return cartListToReturn;
        }catch(Exception e){
            throw new AuraHandledException('Please contact your sales rep with error message - '+ e.getMessage());    
        }
    }
    
    public static GD_Cart__c populateOrderLine(GD_Price_List_Entry__c p ,String inventoryOrgId){
        GD_Cart__c line = new GD_Cart__c();
        
        line.Name = p.GD_Item_Description__c;
        line.GD_Item__c = p.GD_Item__c;
        line.GD_Quantity__c = 0;
        line.GD_Unit_Price__c = p.GD_Unit_Price__c;
        line.GD_UOM__C = p.GD_UOM__c;
        line.GD_Price_List_Entry__c = p.Id;
        line.GD_Inventory_Organization__c = inventoryOrgId; 
        return line;
    }
    
    public static void populateWrapper(GD_Price_List_Entry__c p,String inventoryOrgId){
        system.debug(p.GD_Item_Description__c);
        system.debug('---> POPULATING'+p.GD_Item__c);
        GD_CartProductsWrapper product = new GD_CartProductsWrapper();
        GD_Cart__c line = populateOrderLine(p,inventoryOrgId);
        cartListToReturn.add(line);
        product.cartItem = line;
        product.unitPrice = p.GD_Unit_Price__c;
        mapOfProduct.put(p.Id, product);
    }
    
    public static List<GD_Inventory_Organization__c> getInventoryOrgDetails(){
        Set<Id> inventoryIds = new Set<Id>();
        for(GD_User_Inventory_OrganizationAssignment__c assignment : [SELECT Id,GD_Inventory_Organization__c,GD_User__c FROM GD_User_Inventory_OrganizationAssignment__c WHERE GD_User__c =:userInfo.getUserId()]){
            inventoryIds.add(assignment.GD_Inventory_Organization__c);
            
        }
        
        List<GD_Inventory_Organization__c> inventoryOrgList = new List<GD_Inventory_Organization__c>();
        inventoryOrgList = [SELECT Id,Name,GD_Alias_Name__c FROM GD_Inventory_Organization__c WHERE  Id IN: inventoryIds ];
        
        return inventoryOrgList;
    }
    
    
    
    @AuraEnabled
    public static GD_Cart__c addProductToCart(GD_Cart__c orderLine){
        try{
            if(orderLine.GD_User__c == null){
                orderLine.GD_User__c = userInfo.getUserId();
            }
            system.debug('orderLine '+orderLine);
            Upsert orderLine;
            return orderLine;
        }catch(Exception e){
            
            throw new AuraHandledException(e.getMessage());    
        }
    }
    //GD_Total_Price_Formula__c
    @AuraEnabled
    public static List<GD_Cart__c> getExistingProductsInCart(){
        try{
            List<GD_Cart__c> cartList = new List<GD_Cart__c>();
            cartList = [SELECT id,Name,GD_Item__r.Name,GD_Unit_Price__c,GD_Total_Price_Formula__c,GD_Total_Price_With_Vat__c,GD_Quantity__c,GD_UOM__c,
                        CreatedDate FROM GD_Cart__c WHERE GD_User__c =:userInfo.getUserId() ORDER BY CreatedDate DESC];
            return cartList;
        }catch(Exception e){
            
            throw new AuraHandledException(e.getMessage());    
        }
    }
    
    // Creating wrapper to send data on init.
    public Class InitData{
        @AuraEnabled
        public List<GD_Cart__c> cartProducts;
        
        @AuraEnabled
        public List<GD_Inventory_Organization__c> assignedInventories;
        
        public InitData(){
            cartProducts = new List<GD_Cart__c>();
            assignedInventories = new  List<GD_Inventory_Organization__c>() ;
        } 
    }
    
}



My test class is covered 70% , follwing method is not covering.
 
@AuraEnabled
    public static List<GD_Cart__c> getProductsToDisplay(String pageSize,String pageNumber,String productSearch,String inventoryOrgId){
        try{
            mapOfProduct = new Map<Id,GD_CartProductsWrapper>();
            cartListToReturn = new List<GD_Cart__c>();
            system.debug('Inventory '+inventoryOrgId);
            List<User> loggedInUser = new List<User>();
            loggedInUser = [SELECT Id,Name,Contact.AccountId FROM User WHERE Id=:userInfo.getUserId()];
            Account acc = [SELECT Id,GD_Customer_Class__c,GD_Status__c,GD_Product_List__c,GD_Price_List__c FROM Account WHERE Id=:loggedInUser.get(0).Contact.AccountId];
            // AND GD_Status__c = 'Active' AND GD_Product_List__c != null
            if(acc.GD_Status__c != 'Active'){
                throw new AuraHandledException('Your account is not Active. Please contact sales rep to activate your account.');    
            }
            if(acc.GD_Product_List__c == null){
                throw new AuraHandledException('Please contact your sales rep with error message - Product list not assigned to customer.');    
            }
            if(acc.GD_Price_List__c == null){
                throw new AuraHandledException('Please contact your sales rep with error message - Price list not assigned to customer.');    
            }
            
            system.debug('GD_Product_List__c '+acc.GD_Product_List__c);
            if(acc.GD_Price_List__c != null){
                String priceListId = acc.GD_Price_List__c; 
                Set<Id> portalItemIds = new Set<Id>();
                // GD_Inventory_Organization__c=:inventoryOrgId AND
                for(GD_Portal_Products__c product : [SELECT Id,Name,GD_Item__c FROM GD_Portal_Products__c WHERE GD_Product_List__c=:acc.GD_Product_List__c]){
                    portalItemIds.add(product.GD_Item__c);
                }
                system.debug('---> portalItemIds '+portalItemIds);
                if(portalItemIds.size() > 0){
                    String query = 'SELECT Id,Name,GD_Item_Description__c,GD_Item__c,GD_Price_List__c,GD_Item__r.GD_Inventory__c, ';
                    query += ' GD_Unit_Price__c,GD_UOM__c,GD_Code_UOM_Formula__c FROM GD_Price_List_Entry__c ';
                    query += ' WHERE GD_Price_List__c = :priceListId  AND GD_Item__r.GD_Inventory__c = :inventoryOrgId';
                    query += ' AND GD_Item__r.GD_Segment_3__c = \'A\' ';
                    query += ' AND GD_Item__c IN :portalItemIds ';
                    system.debug('productSearch '+productSearch);
                    if(productSearch != ''){
                        String searchTerm = '%'+String.escapeSingleQuotes(productSearch) +'%';  // assign the search term to a variable
                        query += ' AND GD_Item_Description__c LIKE :searchTerm';
                    }
                    //        query += ' AND GD_Unit_Price__c > 0  ';  
                    query += ' ORDER BY GD_Item_Description__c ';
                    system.debug('pageSize '+pageSize);
                    system.debug('pageNumber '+pageNumber);
                    system.debug('query '+query);
                    
                    ssc = new ApexPages.StandardSetController( Database.getQueryLocator( query ) );
                    system.debug('ssc '+ssc);
                    
                    //set page size
                    ssc.setpagesize(Integer.valueOf(pageSize));
                    //set page number 
                    ssc.setPageNumber(Integer.valueOf(pageNumber));
                    system.debug(' Set Page number');
                    //      accountList =  (List<Account>) ssc.getRecords();
                    system.debug(' Adding account list');
                    List<GD_Price_List_Entry__c> priceList = new List<GD_Price_List_Entry__c>();
                    priceList =  (List<GD_Price_List_Entry__c>) ssc.getRecords();
                    system.debug('---> priceList '+priceList);
                    system.debug('ssc.getHasNext() '+ssc.getHasNext());
                    system.debug('ssc.getHasPrevious()'+ssc.getHasPrevious());
                    //system.debug();
                    system.debug('ssc.getRecords() '+ssc.getRecords());
                    system.debug('priceList '+priceList);
                    List<GD_CartProductsWrapper> cartProducts = new  List<GD_CartProductsWrapper>();
                    
                    List<GD_CartProductsWrapper> listOfProduct = new List<GD_CartProductsWrapper>();
                    List<GD_Order_Line_Item__c> orderLineItem = new List<GD_Order_Line_Item__c>();
                    Map<Id,List<String>> uomList = new Map<Id,List<String>>();
                    for(GD_Price_List_Entry__c p : priceList){
                        populateWrapper(p,inventoryOrgId);
                    }
                }
            }
            return cartListToReturn;
        }catch(Exception e){
            throw new AuraHandledException('Please contact your sales rep with error message - '+ e.getMessage());    
        }
    }



Thanks in Advance,
Soundar.
Hi,

Can anyone please help how to cover a test class for this code ?
 
public class GD_CartProductsWrapper {

    @AuraEnabled
    public GD_Cart__c cartItem;
    
    @AuraEnabled
    public List<String> uomPicklist;
    
    @AuraEnabled
    public Map<String,GD_Cart__c> orderLinesByUom;
    
    @AuraEnabled
    public Decimal unitPrice;
    
    @AuraEnabled
    public Decimal totalPrice;
    
    public GD_CartProductsWrapper(){
        cartItem = new GD_Cart__c();
        uomPicklist = new List<String>();
        orderLinesByUom = new Map<String,GD_Cart__c>();
        totalPrice = 0;
    }
}

Regards,
Soundar.​​​​​​​
Dears,

I would like to cover a test class for this simple code , But i am facing a following Error.
 
Error: Compile Error: Static method cannot be referenced from a non static context: String GD_TradeLicenseRunningBanner.fetchUser() at line 39 column 15



public class GD_TradeLicenseRunningBanner {
   
    @AuraEnabled 
    public static String fetchUser(){        User oUser = [select id,Name,TimeZoneSidKey,contactId,Username,Alias,Country,Email,FirstName,LastName,IsActive,IsPortalEnabled, Contact.accountId   FROM User Where id =: userinfo.getuserId() ];        account acc = [select id,name,GD_General_Info__c from account where id=: oUser.contact.accountId Limit 1];
        return acc.GD_General_Info__c;
    }


}


@Test CLass
 
@isTest
Public class GD_TradeLicenseRunningBannerTest{

@testSetup
    static void testSetupMethod(){
    system.debug('Running Into the test class');
        profile pr = [SELECT Id,Name FROM Profile WHERE Name = 'GD PP Sales Rep'];
        User usr = new User(Alias = GD_TestDataFactory.generateUniqueText(), 
                          Email='test@test.com', 
                          EmailEncodingKey='UTF-8', 
                          LastName='Test', 
                          LanguageLocaleKey='en_US', 
                          LocaleSidKey='en_US', 
                          ProfileId = pr.Id, 
                          TimeZoneSidKey='America/Los_Angeles', 
                          UserName=GD_TestDataFactory.generateRandomUserName());
        Insert usr;
        
        
        account acc = new account();
        acc.name='test';
        insert acc;
        
        contact con = new contact(firstname='testName', lastName='testName', accountId = acc.id);
        insert con;
        
        Opportunity Opp = new Opportunity(Name = 'Test Opp', CloseDate = Date.today());

        
        System.Test.startTest();
        GD_TradeLicenseRunningBanner trade = new GD_TradeLicenseRunningBanner();
        trade.fetchUser();
        System.Test.stopTest();
    }
}



Thanks in advance.
Soundar.
Dears,

I am facing following scenario

1. Need to display a User departmet in lead (Custom) new new page.

2. Owner field is always displaying while creating.

3. Formula filed is not displaying in the new page, It's only available in the detail page.

4. I would like to display a User departmnet (Custom field) as same as owner field.

5. Is that possible ?

Regards,
Soundar.  
Dears,

I am trying to complete PD2 super badges, I am facing following erorr. 
 
Challenge Not yet complete... here's what's wrong:
Inserting a new Maintenance Request of type 'Routine Maintenance' and then closing it did not create of a new Maintenance Request based upon the original record correctly. The challenge is expecting to find the closed Maintenance Request plus an 'New' Maintenance Request of type 'Routine Maintenance' with the same Vehicle as the closed one.

Regards,
Soundar.
Input search text given but output was not displaying

Lightning Component
Component
Controller
ControllerApex Class
Apex ClassOutput Preview
Output
Hi,
Kindly anyone can help on below questions for PD:

Thanks in advance.


1. Create a visualforce page for opportunities that allows user to save or merge the current record. What approach -
A.  Custom Controller
B.  Custom Contoller extension
C.  Visualforce Java Script
D.  Standard Controller Methods.    

2. A developer must build an application that tracks which accounts have purchased specific pieces of equip Products. Each Account could purchase many pieces of equipment.

How should the developer track that an account has purchased a piece of equipment?
A.  Use the Asset object
B.  Use a custom object
C.  Use a Master-Detail on Product to Account
D.  Use a lookup on Account to Product    

 
  • July 05, 2020
  • Like
  • 0
How to write custom message alternative of this message "Review the errors on this page" in salesforce validation rules.
HI,

I would like to display a picklist value from record.

1. I am using one custom object it's called "GD_Offer__c ". I want to display a field as  a picklist with reference of "GD_Offer__c" records.

2. For example i have 3 following records in this "GD_Offer__c" table, I need to display those records in picklist value.

       A. Offer A
       B. Offer B
       C. Offer C


I wrote coding for this functionality, I am not sure where i did a mistake. Can you please guide me where i did a mistake and what are all the changes i need to do to achieve mentioned functionality.


Apex Class Method 
@AuraEnabled 
     public static Map<String, String> getOffers(){
        system.debug('Entered into the Get Offers ********'); 
        Map<String, String> options = new Map<String, String>();
        Schema.DescribeFieldResult fieldResult = GD_Offers__c.Name.getDescribe();
         system.debug('fieldResult | ' + fieldResult);
        List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues();
         system.debug('pList ' + pList);
        for (Schema.PicklistEntry p : pList) {
            options.put(p.getValue(), p.getLabel());
        }
        system.debug('Options |' + options);
        return options;
    }

Component
 
<aura:attribute name="offerMap" type="Map"/>

<table>
<tr>
<td>
                            <lightning:recordEditForm aura:id="form" objectApiName="GD_Quote_Line_Items__c" >
                               
                                <div class="form-group">
                                    <lightning:select aura:id="industryPicklist" value="{!v.lineItem.GD_Offers__c}" onchange="{!c.handleCompanyOnChange}">
                                        <option value="">--None--</option>
                                        <aura:iteration items="{!v.offerMap}" var="ind" indexVar="key">
                                            <option text="{!ind.value}" value="{!ind.key}" selected="{!ind.key==v.lineItem.GD_Offers__c}" />
                                        </aura:iteration>
                                    </lightning:select>
                                </div>
                            </lightning:recordEditForm>
                        </td>
</tr>
</table>

Controller.JS
doInit: function(component, event, helper) {
        helper.getOfferPicklist(component, event);
    },

Helper.JS
getOfferPicklist: function(component, event) {
        alert('Entered Offer Picklist');
        var action = component.get("c.getOffers");
        action.setCallback(this, function(response) {
            var state = response.getState();
            alert('State = ' + state);
            if (state === "SUCCESS") {
                var result = response.getReturnValue();
                var offerMap = [];
                for(var key in result){
                    offerMap.push({key: key, value: result[key]});
                }
                component.set("v.offerMap", offerMap);
            }
        });
        $A.enqueueAction(action);
    },


Thanks In Advance,
Soundar.
Thanskn
Hi,

I am sharing Opportunity record from Quote team members. In This scenario i would like to add one more functionality as mentioned below.

1. As of now this functionality is working for add a new team members.

2. But if already this record has shared to User A, Again i am sharing to same User A. At that time system should update a Old record with latest update (Without Creating a new record).

3. I am little confused to launch this functionality.

Can you please check my code and let me know where i need to make a changes to achieve metioned functionality.


Code For Review
 
public with sharing class GD_CreateQuoteTeam { 
    @AuraEnabled
    public static void saveQuoteTeam(List<GD_Quote_Team__c> teamList, string quoteId){
        try{
            list<GD_Quote_Team__c> qtTeamList = new list<GD_Quote_Team__c>();
            list<opportunityShare> readShareList = new list<opportunityShare>();
            list<opportunityShare> editShareList = new list<opportunityShare>();    
            
            GD_Quote__c qt = [select id,GD_Opportunity__c from GD_Quote__c where id =: quoteId];
            id oppId = qt.GD_Opportunity__c;
            system.debug('Opportunity Id '+ oppId);
            for(GD_Quote_Team__c team : teamList){
                team.GD_Quotes__c = quoteId;
                qtTeamList.add(team);
            }
            if(qtTeamList.size()>0){Insert qtTeamList;}
            
            for(gd_quote_Team__c qTeam : qtTeamList){
                if(qTeam.GD_Quote_Access__c == 'Read Only'){
                    system.debug('Enter Into the Read only = ' + qTeam.GD_Quote_Access__c);
                    opportunityShare shareRecord = new opportunityShare();
                    shareRecord.OpportunityAccessLevel = 'Read';
                    shareRecord.UserOrGroupId = qTeam.GD_user__c;
                    shareRecord.OpportunityId = oppId;
                    readShareList.add(shareRecord);
                }    
            }
            if(readShareList.size()>0){insert readShareList;system.debug('Read Access Provided');}        
            
            for(gd_quote_Team__c qTeam : qtTeamList){  
                if(qTeam.GD_Quote_Access__c == 'Read/write'){
                    system.debug('Access |' + qTeam.GD_Quote_Access__c);
                    opportunityShare shareRecord = new opportunityShare();
                    shareRecord.OpportunityAccessLevel = 'edit';
                    shareRecord.UserOrGroupId = qTeam.GD_user__c;
                    shareRecord.OpportunityId = oppId;
                    editShareList.add(shareRecord);
                } 
            }
            if(editShareList.size()>0){insert editShareList;system.debug('Edit Access Provided');} 
        }catch(Exception e){system.debug('Exception -' + e);}
        
    }
    
}


Thanks in advance,
Soundar Rajan P.
 
Hi,

I tried in many way but lightning quick action is not possible in lightnig related list button.

I found few ideas also
https://success.salesforce.com/ideaView?id=0873A0000003TXFQA2

But i am expecting an alternate way to implement this functionality.

Can anyone please help me to achieve this functionality .


Regards,
Soundar.
Hi,

I am trying to share a custom quote record to user's. But i am facing following error.
This Record is having "Control By Parent" access.
Even i tried with opportunity as a parentId.
DEBUG|Exception -System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Parent ID: id value of incorrect type: a0g0C000001NvFxQAK: [ParentId]

Can you please tell me where i did  a mistake and how can i achieve it in a success way.
 
public class GD_CreateQuoteTeam { 
    @AuraEnabled
    public static void saveQuoteTeam(List<GD_Quote_Team__c> teamList, string quoteId){
        try{
        list<GD_Quote_Team__c> qtTeamList = new list<GD_Quote_Team__c>();
        list<GD_Quote_Team__Share> readShareList = new list<GD_Quote_Team__Share>();
        list<GD_Quote_Team__Share> editShareList = new list<GD_Quote_Team__Share>();
        for(GD_Quote_Team__c team : teamList){
            team.GD_Quotes__c = quoteId;
            qtTeamList.add(team);
        }
        Insert qtTeamList;
        /*Share Record - Read Only*/
        for(gd_quote_Team__c qTeam : [select id,name,GD_user__c from gd_quote_Team__c where GD_Quotes__c =: quoteId and GD_Quote_access__c = 'Read Only']){
            GD_Quote_Team__Share shareRecord = new GD_Quote_Team__Share();
                shareRecord.AccessLevel = 'Read';
                shareRecord.UserOrGroupId = qTeam.GD_user__c;
                shareRecord.ParentId = quoteId;
                readShareList.add(shareRecord);
        }
        if(readShareList.size()>0){insert readShareList;}        
        /*Share Record - Read/Write*/
        for(gd_quote_Team__c qTeam : [select id,name,GD_user__c from gd_quote_Team__c where GD_Quotes__c =: quoteId and GD_Quote_access__c = 'Read/write']){
            GD_Quote_Team__Share shareRecord = new GD_Quote_Team__Share();
                shareRecord.AccessLevel = 'edit';
                shareRecord.UserOrGroupId = qTeam.GD_user__c;
                shareRecord.ParentId = quoteId;
                editShareList.add(shareRecord);
        }
        if(editShareList.size()>0){insert editShareList;} 
            }catch(Exception e){system.debug('Exception -' + e);}
        
    }
    
}

Many Thanks in Advance.
Soundar Rajan P.
Hi,

Email notification is not sending after sharing the record. Can anyone please check and where i did a mistake.
 
public static void GD_shareOrderWithStoreUser(Map<Id,GD_Order__c> newMap, Map<Id,GD_Order__c> oldMap){
        
        List<GD_Order__c> ordersToShare = new List<GD_Order__c>();
        
        for( GD_Order__c order : newMap.values()) {
            if(order.GD_Type__c == 'Online Order' && 
               order.GD_Status__c != oldMap.get(order.Id).GD_Status__c  
               && order.GD_Status__c == 'Accepted' && order.GD_Sales_Rep__c != null ){
                   ordersToShare.add(order);
                   system.debug('*Order to share ***' + order.name);
               }
        }
        
        if(ordersToShare.size() > 0){
            List<GD_Order__Share> orderShareList = new List<GD_Order__Share>();

            Map<String,Group> groupIdByName = new Map<String,Group>();
            Map<String,List<Id>> usersByGroup = new Map<String,List<Id>>();
            
            for(Group grp : [SELECT Id,DeveloperNAME,(SELECT Id,UserOrGroupId FROM GroupMembers) FROM Group 
                             WHERE  DeveloperNAME = 'Pharma_Store_Dubai' OR DeveloperNAME = 'Pharma_Store_Abu_Dhabi']){	
                                 if(grp.DeveloperNAME ==  'Pharma_Store_Dubai'){
                                     groupIdByName.put('Dubai', grp);
                                 }
                                 if(grp.DeveloperNAME ==  'Pharma_Store_Abu_Dhabi'){
                                     groupIdByName.put('Abu Dhabi', grp);
                                 }
                                 for(GroupMember gm : grp.GroupMembers){
                                     if(grp.DeveloperNAME ==  'Pharma_Store_Dubai'){
                                         if(usersByGroup.containsKey('Dubai')){
                                             usersByGroup.get('Dubai').add(gm.UserOrGroupId);
                                         }else{
                                             usersByGroup.put('Dubai',new List<Id>{gm.UserOrGroupId});
                                         }
                                     }else if(grp.DeveloperNAME ==  'Pharma_Store_Abu_Dhabi'){
                                         if(usersByGroup.containsKey('Abu Dhabi')){
                                             usersByGroup.get('Abu Dhabi').add(gm.UserOrGroupId);
                                         }else{
                                             usersByGroup.put('Abu Dhabi',new List<Id>{gm.UserOrGroupId});
                                         }
                                     }
                                 }
                             }
            if(groupIdByName.size() > 0){
                List<EmailTemplate> templateList = [SELECT Id,Body FROM EmailTemplate 
                                                    WHERE DeveloperName ='GD_Email_Notification_to_Approvers'];
                List<Messaging.SingleEmailMessage> sendEmailNotification = new List<Messaging.SingleEmailMessage>();
                
                for( GD_Order__c order : ordersToShare) {
                    if(groupIdByName.containsKey(order.GD_Pharma_Location__c)){
                        GD_Order__Share shareRecord = new GD_Order__Share();
                        shareRecord.AccessLevel = 'Edit';
                        shareRecord.UserOrGroupId = groupIdByName.get(order.GD_Pharma_Location__c).Id;
                        shareRecord.ParentId = order.Id;
                        system.debug('shareRecord '+shareRecord);
                        orderShareList.add(shareRecord);
                        if(templateList.size() > 0){
                            if(usersByGroup.containsKey(order.GD_Pharma_Location__c)){
                                for(Id storeUserId : usersByGroup.get(order.GD_Pharma_Location__c)){
                                    system.debug('Store User Email |' + storeUserId);
                                    Messaging.SingleEmailMessage mail = Messaging.renderStoredEmailTemplate(templateList.get(0).Id, storeUserId, order.Id);
                                    String emailSubject = mail.getSubject();
                                    String emailTextBody = mail.getPlainTextBody();
                                    mail.setSubject(emailSubject);
                                    mail.setPlainTextBody(emailTextBody);
                                    mail.setSaveAsActivity(false);
                                    mail.setTargetObjectId(storeUserId); 
                                    sendEmailNotification.add(mail);
                                }
                            }
                        }
                    }
                } 
                if(orderShareList.size () > 0){
                    Insert orderShareList;
                }
                if(sendEmailNotification.size() > 0){
                    system.debug('sendEmailNotification.size()' + sendEmailNotification.size());
                    List<Messaging.SendEmailResult> results = Messaging.sendEmail(sendEmailNotification);
                }
                
            }
        }
    }

Regards,
Soundar.
We have 7 Communities in our Org. 4 Communities with  Visual Force+Tabs template and 3 Communities on Custome Service Template(Lighting).

Our Company Custom domain is www.abc.com 

Currently, our Community URL's are set up under the Custom domain. We did all the CName , DNS etc.. all the stuff that is required to have our own branded URL's.

https://Community1.AxxBxxCxx.com
https://Community2.AxxBxxCxx.com
https://Community3.AxxBxxCxx.com
https://Community4.AxxBxxCxx.com
https://Community5.AxxBxxCxx.com
​​​​​​https://Community6.com
https://ABC.force.com/Community7

Question:
As we keep adding more communities to our Org we would like to have one URL for all the communities something like www.ourcompany.communities.com
The idea is when a user enters through this URL we take them to a login page and then based on the credentials they provide we take them to the appropriate community.
Is this possible? And if it is possible would it be a problem with having different community templates.

Thanks,
Goutham. 
Hi Community,

I have enabled multi-currency in my org (sandbox and production, LEX), but I have two different Account CurrencyISOCode field behaviour:
  • Sandbox (Winter19, Unlimited Edition): the currency field is displayed on edit mode but is not displayed in detail page.
  • Production (Summer18, Unlimited Edition): the currency field is displayed on edit mode and in detail page.
The currency field is showing up on the payout layout editor. I have checked Field Accessibility and Field Level Security and both are okay (both orgs with the same configuration).
I need to hide the field in for the Account Layout (detail page), but I am not able in PROD. 

I found some issues that could be related to this topic, but is not clear:
  • https://success.salesforce.com/answers?id=90630000000ZjjFAAS
  • https://help.salesforce.com/articleView?id=000004023&type=1
  • https://success.salesforce.com/answers?id=90630000000goIKAAY
Please any feedback on this? Truly appreciated.

Thanks in advance,
Natalia
I need to display all account records in a picklist in a flow.
On selection of 1 record, I need to ask few survey questions and save it to a custom object.

How to achieve this.How to display all records in picklist,Is it possible??

Thanks
Laxman
Input search text given but output was not displaying

Lightning Component
Component
Controller
ControllerApex Class
Apex ClassOutput Preview
Output