• Sanjay Bhati 95
  • NEWBIE
  • 160 Points
  • Member since 2017
  • Certified Salesforce Developer
  • Dazeworks


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 68
    Replies
Hello,

How to cover this portion.Please help with sample code.

@future (callout=true)
    Public static void smsCustomer1(Id tskId) {
        SMS_Settings__c smsS = [select id, Name, senderId__c,task_sms__c,Mobile_Number__c, ValueFirst_Username__c, ValueFirst_Password__c from SMS_Settings__c where name ='Proposal'] ; 
        Task tsk = [select id,Status,Proposal_Number__r.Account_Name__r.FirstName,Proposal_Number__r.Account_Name__r.LastName,Proposal_Number__r.Account_Name__r.PersonMobilePhone 
                    from Task where id=:tskId];
                                            
        String fromNo = smsS.senderId__c; //'PGFIIT';
        String toNo =  '91' + tsk.Proposal_Number__r.Account_Name__r.PersonMobilePhone; // '919790882125'; // 
        String Name = tsk.Proposal_Number__r.Account_Name__r.FirstName + ' '+ tsk.Proposal_Number__r.Account_Name__r.LastName; 
        String message = smss.task_sms__c.replace('CUSTNAME', Name);
        String xmlMessage = '<?xml version="1.0" encoding="ISO-8859-1"?>';
                xmlMessage += '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd" >';
                xmlMessage += '<MESSAGE><USER USERNAME="'+smss.ValueFirst_Username__c+'" PASSWORD="'+smss.ValueFirst_Password__c+'"/>';
                xmlMessage += '<SMS UDH="0" CODING="1" TEXT="'+message +'" PROPERTY="0" ID="'+tskId+'">';
                xmlMessage += '<ADDRESS FROM="'+ fromNo +'" TO="'+toNo +'" SEQ="1" TAG="Premium Payment" />';
                xmlMessage += '</SMS></MESSAGE>';
        String encodedUrl = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2?action=send&data='+EncodingUtil.urlEncode(xmlMessage, 'UTF-8');
        String decodedUrl = EncodingUtil.urlDecode(encodedUrl, 'UTF-8');  system.debug(decodedUrl);
        Http h = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint(encodedUrl); 
        req.setMethod('GET');
        if (test.isRunningTest()!=true) {
            HttpResponse res = invokeWebService(h, req); handleWebServiceResponseCust(tskId);
            system.debug(res.getBody());
        } else {
            handleWebServiceResponseCust(tskId);
        }
I have test classes that have been built using the @IsTest(SeeAllData=true) however, to my understanding it's not the best practice. Do I need to rewrite new test.classes using @IsTest(SeeAllData=false) or can I just replace the original code and then redeploying via a force.com tool?
<aura:component controller="VerificationFilesController" Implements="flexipage:availableForRecordHome,force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="force:refreshView" action="{!c.doInit}" />
    <aura:attribute name="recordError" type="String" access="private"/>
<aura:attribute name="isMultiSelectOpen" type="boolean" />
    <aura:attribute name="options" type="List" default="[]"/>
    <aura:attribute name="values" type="List" default="[]"/>
<lightning:button variant="brand" label="Request for Additional Documents" title="Request for Additional Documents" onclick="{!c.openMultiSelectModel}"/>
    <aura:if isTrue="{!v.isMultiSelectOpen}">
        <!--###### MODAL BOX Start From Here ######--> 
        <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
            <div class="slds-modal__container">
                <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
                <div class="slds-modal__header">
                    <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeReviewer}">
                        X
                        <span class="slds-assistive-text">Close</span>
                    </button>
                    <h2 id="header99" class="slds-text-heading--medium">Review Document</h2>
                </div>
                <!--###### MODAL BOX BODY Part Start From Here ######-->
                <div class="slds-modal__content slds-p-around--medium  slds-is-relative slds-scrollable">
                    <aura:if isTrue="{!v.showSpinner}">
                        <div class="demo-only" style="height:6rem;">
                            <div role="status" class="slds-spinner slds-spinner_medium slds-spinner_brand">
                                <span class="slds-assistive-text">Loading</span>
                                <div class="slds-spinner__dot-a"></div>
                                <div class="slds-spinner__dot-b"></div>
                            </div>
                        </div>
                        <aura:set attribute="else">
                            <div class="slds-form-element slds-p-around--medium">

        <lightning:dualListbox aura:id="selectOptions"
                                               name="multipleOptions"  
                                               label= "Select Options" 
                                               sourceLabel="Available Options" 
                                               selectedLabel="Selected Options" 
                                               options="{!v.options}" 
                                               value="{!v.values}" 
                                               onchange="{!c.handleChange}"/>     
 </div>
                        </aura:set>
                    </aura:if>
                </div>
                    <button class="slds-button slds-button--neutral" onclick="{!c.closeReviewer}" >Cancel</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--open"></div>
        <!--###### MODAL BOX Part END Here ######-->
        

    </aura:if>
({
    doInit: function(component, event, helper) {         
        var action1 = component.get('c.getTypeWiseDocuments');
        //var typewisedocument = component.find("selectOptions");
        action1.setCallback(this, function(response1) {
            var state = response1.getState();
            if (component.isValid() && state == 'SUCCESS') { 
            var documents = response1.getReturnValue();
            var options = [];
            documents.forEach(function(document)  { 
                    console.log(document);
                    options.push({ value: document.Document_Name__c, label: document.Document_Name__c});
                });
                component.set("v.options", options);
                component.get("v.values");
                alert(JSON.stringify(component.get("v.options")));
            } else {
                console.log('Failed with state: ' + state);
            }
         });
        $A.enqueueAction(action1);
        
    },
handleChange: function (cmp, event) {
        // This will contain an array of the "value" attribute of the selected options
      
         var selectedOptionValue =event.getParam("value");
        alert("Option selected with value: '" + selectedOptionValue.toString() + "'");         
    },
     openMultiSelectModel: function(component, event, helper) {
        // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
        component.set("v.isMultiSelectOpen", true);
        alert(component.get("v.isMultiSelectOpen"));
    },
    closeMultiSelectModel : function(component, event, helper) {
        component.set("v.isMultiSelectOpen", false);
    }
})
public class VerificationFilesController {
@AuraEnabled
    public static List<TypeWiseDocument__c> getTypeWiseDocuments(){
        system.debug('getTypeWiseDocuments Controller');
        List<TypeWiseDocument__c> twList = [SELECT  ID,Document_Name__c FROM TypeWiseDocument__c where DocumentType__c = 'Additional'];
        return twList;        
    }
}



 
I have created a customer object called Internal Team Members in which users will be assigned a role for a project. I need the owners of these records to match the user identified and assigned a role within the object. 

Any help would be greatly appreciated. Thank you in advance. 
I am a newbie to salesforce and I am doing a project on hospital management system in it. I have Objects for Hospitals, Wards & Patients. Patient is in a lookup relationship with Ward and Hospital. In Ward I have a picklist called ward type(values: General, ICU, HCU, ICCU, Cabin). In Patient Object I also have a similar picklist called ward type but here I want to display only those wards which are available in the hospital where the patient is getting admitted(for e.g, ICCU and HCU are not present in every hospital so it is meaningless to show those options in ward type of such hospitals while filling a new patient detail).

Other than salesforce I could query the database of Ward object filtered by hospital name entered and put the options in the drop-down list but I do not know how to put options in picklist in real-time fetching the records of wards, filtered by hospital name entered by the user in salesforce.

Plz help if you know anything in this regard :)
I am getting an error System.LimitException: Too many SOQL queries: 101 .
my code.
trigger contactaccountrelation on Contact (before insert) {
 
       list<account> acc = [select id, name from account];
    for(account a : acc){
    for(contact con : [select lastname, accountid from contact where accountid =: a.id]){
        con.OtherPhone = a.Phone;
    }
    }
}
Hello everyone,

I'm have a table which shows the list of Opportunities. I want to show an inner table whenever an opportunity row is clicked. Similar to the following. However, i'm unable to achieve this & not sure what i might be missing. Please share your inputs. Thanks in advance!
<table>
                        <thead >
                            <tr>
                                <th>Opportunity</th>
                                <th>Type</th>
                                <th>Start</th>
                                <th>End</th>
                                <th>Budget</th>
                                <th>More ($)</th>
                            </tr>
                        </thead>
                        <tbody>
                            <apex:repeat value="{!wrap}">
                                <tr>
                                    <td>{!wrap.a}</td>
                                    <td>{!wrap.b}</td>
                                    <td>{!wrap.c}</td>
                                    <td>{!wrap.d}</td>
                                    <td>{!wrap.e}</td>
                                    <td>{!wrap.f}</td>
                                </tr>
                                
                                <!--Inner Table-->
                                <tr>
                                    <div>
                                    <table id="newtable">
                                        <thead id="newth">
                                            <tr>
                                                <th colspan="1">Jan</th>
                                                <th colspan="1">Feb</th>
                                                <th colspan="1">Mar</th>
                                                <th colspan="1">Apr</th>
                                                <th colspan="1">May</th>
                                                <th colspan="1">Jun</th>
                                                <th colspan="1">Jul</th>
                                                <th colspan="1">Aug</th>
                                                <th colspan="1">Sep</th>
                                                <th colspan="1">Oct</th>
                                                <th colspan="1">Nov</th>
                                                <th colspan="1">Dec</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                
                                        </tbody>
                                    </table>
                                    </div>
                                </tr>                                    
                            </apex:repeat>
                        </tbody>
                    </table>

I'm trying to something similar & even tried the following example which didnt work. 
https://www.soliantconsulting.com/blog/multi-tiered-tables-in-visualforce/?unapproved=382305&moderation-hash=7a67877d361da32c66a3507d496a06c3#comment-382305
Hi,

I am getting a CPU Time-Out error message with reference to the trigger below.

The only records I want to be triggered are records that match the IF criteria, however all records will be processed within the loop.

When I add 800 test records that dont even meet the critera, im getting the CPU error.

What would be the best practice to only process the records that meet the criteria beofore entering the loop? 
 
trigger accountTrigger on Account (before insert, before update, after insert, after update) {
    
    if(Trigger.isBefore)
    {
        if(Trigger.isInsert) // Run only BEFORE Insert 
        {
            
            
        }
        
        if(Trigger.isUpdate) // Run only BEFORE update
        {
            
            
        }
        
        if (Trigger.isInsert || Trigger.isUpdate) {

            for(Account acc: Trigger.new){
               

                if (acc.EFCAIS__Status__c != NULL && acc.PersonBirthdate != Null){
                    
                    academyCriteriaHandler.calculateAgeInformationCriteria(Trigger.new, Trigger.oldMap, Trigger.newMap);
                } 
            }
            
        }
    }


 
compile fine, but now I am ready to move them to production.  I have been researching the basics of writing test classes, but it definitely seems a bit overwhelming in terms of where to begin, etc.  as an example, If i have an apex class (e2), and I am writing a unit Test class for this class, would the name of the test class be public class e2Test (after the @istest keyword)? when i run a test class through the developer console and choose the test class (e2Test) how does it get associated with the actual class e2??  
I have a node application deployed on heroku that authenticates with salesforce using oauth2 webflow using connected app. I want to create a tab in salesforce that directly lands to the homepage of node app after authenticating with the logged in salesforce user. Initially I created a web tab but due to content security policy I was unable to load the page. Then I tried creating a canvas app but it also causes mixed content problem as we are redirected to http instead of https during oauth2 webflow. Is there any other way to achieve this?
Hey Everyone,

Getting this error on lead conversion:

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Status]: [Status]

I have also checked that LeadStatus is also set as Qualified.

Please help me there.

Hi,
I have created a lightning component which should display/fetch the editable fields of the object from the current record id dynamically.
I added this component to a global action and added the action in the record page layout.
If I place the same button in any object record page it will display the fields dynamically from the current record id using keyprefix of the id.

Below is the image of the fields available in lead object. 

User-added image 
I want this fields to display in a new browser tab with the same record page ID and should happen with other SObject also

How to write a trigger code with handler class to copy few field value from one object (A)to another object (B) ?


Condition :1
Object A

picklist Field : Subodh            Salary =5000
picklist Field : Subodh             Salary =7000

Object B 
picklist Field : Subodh       Total Salary :12000

Condition : 2

Object : A

picklist Field : Subodh             Salary =7000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                  Salary =5000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                   Salary =5000


Object : B

picklist Field : Subodh            Total Salary =7000
picklist Field : Rahul               Total Salary =14000
picklist Field : Amit                  Total Salary =10000


Thanks
Subodh
I am looking for suggestions on a solution I am trying to build. Let me try to explain. 

Here are my objects. Notice__c, Notification__c, Notice Group__c, Notice Group Member__c

I want to be able to create a Notice record. Each Notice is related to a Notice Group. Each Notice Group has a set of Notice Group Members__c. Once a Notice it published (status value = published), a notification record should be created for each Notice Group Member__c associated with the selected Notice Group.

The purpose is to create a notice for an audience of users, but allow individual tracking of the timing of notice acknowledgement. Therefore, each user has their own clone of the Notice record to interact with.

I am trying to evaluate the best way to implement this solution using any combination of workflow tools / Apex. Thanks!


 

I'm trying to generate a conditional autonumber based on a field value.  I'm trying to round robin leads based on field being changed to "Demo Scheduled". 

I'm looking for the code to use in building the trigger. Can anyone help me with that?

Any help would be great! I'm stuck.

Thanks.

Developer console is Salesforce's way for us to check debug logs, track governor limit issues, run queries, and generally just debug all of our developer stuff.... and yet, it's TERRIBLE.

It freezes constantly, it often says it couldn't finish "long running operations", switching perspectives causes the whole browser to lock up, and then once the perspective finally changes it takes a huge amount of time to go from tab to tab (if you can go at all). Once it freezes/crashes, good luck getting it back up because it takes forever to load (if it even loads at all).

This thing is supposed to be our lifeline, our tool to help figure out what's wrong, and I can't even get it to work. Is there an alternative to this poorly implemented program? I can't stand this anymore, I've been trying to suffer through it for 3-4 years now and enough is enough. Why do more people not complain about this tool, and why has Salesforce not released something better by now?

Hi all,

 

From the below query, I want to get the field names provided in the query from the result 'obj' dynamically.

 

sObject obj =[Select id,  Owner, Additional_Info__c, Replacement_Info__c, Phone, Mobile__c,Comments__c from Account where ID =:ID];

 

Regards,

Shylaja