• Manish Bhati
  • SMARTIE
  • 543 Points
  • Member since 2016
  • Salesforce Developer


  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 99
    Replies
Hello,
   I want to know about "DevOps AWS".

Your knowledge will be appreciating.

Thanks
Shephali
Hai All

I have an requirement that when i enter account name in text box click on submit it display all the related contact records 
Please check my code

public class conbyacc {
    public String accname{set;get;}
    public list<Account> acclist{set;get;}
    public list<Contact> conlist{set;get;}
    public set<Account> accids{set;get;}
    public list<Contact> getcons(){
        acclist.clear();
        conlist.clear();
        accids.clear();
        acclist=[select Id,name from Account where name=:accname];
        for(Integer i=0; i<acclist.size(); i++){
            accids.add(acclist[i].Id);  // Getting Error
        }
        conlist=[select name,accountid from Contact where accountid IN:accids];
        return conlist;
        
    }

}


Thanks In Advance
Sampath Palli
I need help to somehow break this trigger as It is not allowing me to change ownership of a lead due to activities assigned to users. I'm not a developer and someone had created this Apex Trigger below.  I tried to inactivate this by creating a change set and deploying into production, however, it keeps giving me the following error message when I am deploying: "System.AssertException: Assertion Failed: Event: The Owner Id is not updating: Expected: 005W00000039nhYIAQ, Actual: 005U0000006SDUqRBO 
Stack Trace: Class.LeadOwnerChangeReassignEvent_test.test: line 32, column 1"


The Apex Trigger is as follows:
trigger LeadOwnerChangeReassignEvent on Lead (before insert, before update, after update) {
    //if(Trigger.IsInsert){
    if(Trigger.IsBefore){   
        List<User> u = [Select id, name, username,email from USER where name like '%Bastian Spekker%'];
        for (Lead l : trigger.new){
            String add = (l.City!=null?l.City.toLowercase():'')+'-'+(l.Street!=null?l.Street.toLowercase():'')+'-'+(l.State!=null?l.State.toLowercase():'')+'-'+(l.Country!=null?l.Country.toLowercase():'');
            if(add.contains('Australia') && u!=null && u.size()>0){
                l.OwnerId = u[0].id;    //Assuming Bastian is queried above
                System.debug('***Updating owner to '+l.OwnerId);
               
            }
        }
    }
    if(Trigger.IsUpdate && Trigger.IsAfter){
        List<Event> events;
        List<Task> tasks;
        List<Id> leadIds = new List<Id>();
       
        for (Lead l : trigger.new)
            if(trigger.newMap.get(l.Id).OwnerId != trigger.oldMap.get(l.Id).OwnerId)
                leadIds.add(l.id);
       
        events = [SELECT Id, WhoId, ScheduleOnce__Event_status__c, EndDateTime FROM Event WHERE WhoId in :leadIds];
       
        for (Lead l : trigger.new) {
            for (Event e : events) {
               if (l.Id == e.WhoId && ( e.EndDateTime < date.Today() ||
                   ( e.ScheduleOnce__Event_status__c != 'Completed'
                     && e.ScheduleOnce__Event_status__c != 'Canceled (rescheduled by Customer)'
                     && e.ScheduleOnce__Event_status__c != 'Canceled by Customer'
               && e.ScheduleOnce__Event_status__c != 'Canceled (reschedule requested by Owner)'
                     && e.ScheduleOnce__Event_status__c != 'Canceled by Owner'
                     && e.ScheduleOnce__Event_status__c != 'No-Show'
                  ))) e.OwnerId = l.OwnerId;
            }
        }
        if (events.size() != 0) update events;
 
      tasks = [SELECT Id, WhoId, isClosed FROM Task WHERE WhoId in :leadIds];
       
        for (lead l : trigger.new) {
            for (Task t : tasks) {
                if (l.id == t.WhoId && !t.isClosed) {
                    t.OwnerId = l.OwnerId;               
                }
            }
        }
        if (tasks.size() != 0) update tasks;
    }
}
trigger LeadOwnerChangeReassignEvent on Lead (before insert, before update, after update) {
    //if(Trigger.IsInsert){
    if(Trigger.IsBefore){   
        List<User> u = [Select id, name, username,email from USER where name like '%Bastian Spekker%'];
        for (Lead l : trigger.new){
            String add = (l.City!=null?l.City.toLowercase():'')+'-'+(l.Street!=null?l.Street.toLowercase():'')+'-'+(l.State!=null?l.State.toLowercase():'')+'-'+(l.Country!=null?l.Country.toLowercase():'');
            if(add.contains('Mexico') && u!=null && u.size()>0){
                l.OwnerId = u[0].id;    //Assuming Bastian is queried above
                System.debug('***Updating owner to '+l.OwnerId);
               
            }
        }
    }
    if(Trigger.IsUpdate && Trigger.IsAfter){
        List<Event> events;
        List<Task> tasks;
        List<Id> leadIds = new List<Id>();
       
        for (Lead l : trigger.new)
            if(trigger.newMap.get(l.Id).OwnerId != trigger.oldMap.get(l.Id).OwnerId)
                leadIds.add(l.id);
       
        events = [SELECT Id, WhoId, ScheduleOnce__Event_status__c, EndDateTime FROM Event WHERE WhoId in :leadIds];
       
        for (Lead l : trigger.new) {
            for (Event e : events) {
               if (l.Id == e.WhoId && ( e.EndDateTime < date.Today() ||
                   ( e.ScheduleOnce__Event_status__c != 'Completed'
                     && e.ScheduleOnce__Event_status__c != 'Canceled (rescheduled by Customer)'
                     && e.ScheduleOnce__Event_status__c != 'Canceled by Customer'
               && e.ScheduleOnce__Event_status__c != 'Canceled (reschedule requested by Owner)'
                     && e.ScheduleOnce__Event_status__c != 'Canceled by Owner'
                     && e.ScheduleOnce__Event_status__c != 'No-Show'
                  ))) e.OwnerId = l.OwnerId;
            }
        }
        if (events.size() != 0) update events;
 
      tasks = [SELECT Id, WhoId, isClosed FROM Task WHERE WhoId in :leadIds];
       
        for (lead l : trigger.new) {
            for (Task t : tasks) {
                if (l.id == t.WhoId && !t.isClosed) {
                    t.OwnerId = l.OwnerId;               
                }
            }
        }
        if (tasks.size() != 0) update tasks;
    }
}
 
I am writing a validation code that checks if the module and division of the module of another meet some criteria:
Long decVal = Long.ValueOf(tmp);
Integer reminder = Modulo529(decVal);
Integer cociente = reminder/23;
Integer residuo = math.mod(reminder,23);

public Integer Modulo529(Long x){
        Long result;
        Long div = 529;
        result = (x/div);
        result = x - (529 * result);
        return Integer.valueOf(result);
}
My problem is that given some number (0987543210987654) the result of the module is wrong, the simple division of that number should be 1866811362925, instead it is 186681136292, it loses the last digit (5), it should be inside the range of 2^63 - 1.
Could you help me?
Thank you very much.
Hi  i have replicated the duplicate management rule in Apex class for  Account Object. But am getting only 64% code coverage. Can anyone help me to increase the code coverage.
User-added image
Am trying to use javascript in a very simple VF page but it is not working can anybody please help me to find out the error.
<----------------PAGE---------------->
<apex:page controller="Example2">

 <script type="text/javascript">
 
    function validate()
    {
        if(document.getElementById('{!$Component.frm.pb.pbs.pbsi1.aa}').value == '')
        {
            alert("FIRST NAME is mandatory");
        }
        if(document.getElementById('{!$Component.frm.pb.pbs.bb}').value == '')
        {
            alert("LAST NAME is mandatory");
        }
         else
        {
            callmove();
            alert("NAME has been inserted CONCATINATED");
        }
    }
        
  </script>  
  <apex:form id="frm"> 
  <apex:actionFunction action="{!move}" name="move" reRender="pb"/>  
   <apex:pageBlock id="pb">   
    <apex:pageBlockSection id="pbs">
               <apex:pageBlockSectionItem ><apex:outputLabel value="FIRST NAME"/></apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="pbsi1"><apex:inputText value="{!aa}" id="aa"/></apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem ><apex:outputLabel value="LAST NAME"/></apex:pageBlockSectionItem> 
            <apex:pageBlockSectionItem id="pbsi2"><apex:inputText value="{!bb}" id="bb"/></apex:pageBlockSectionItem>
       <apex:pageBlockSectionItem ><apex:outputLabel value="FULL NAME"/></apex:pageBlockSectionItem> 
            <apex:pageBlockSectionItem id="pbsi3"><apex:inputText value="{!cc}" id="cc"/></apex:pageBlockSectionItem>        
    </apex:pageBlockSection>    
      <apex:pageBlockButtons location="bottom" >      
    <apex:commandButton value="CONCAT" action="{!move}" onclick="move();"/>
        </apex:pageBlockButtons>  
   </apex:pageBlock>
     </apex:form>
 </apex:page>

<----------------CLASS---------------->
public class Example2 {

    public PageReference move() {
    cc=aa+bb;
        return null;
    }

public string aa{get;set;}
public string bb{get;set;}
public string cc{get;set;}
 
public pagereference getMove() {
cc=aa+bb;
return null;
        
    }

}
Hello All,
public class AccRatingUpdate
{
    list<account> acclist=[select id, name , rating from account];
    for(account acc: acclist)
    {
      
        
    }
}

kindly help me with the above code and its error
 
I created a validation rule to make sure State field can only contain 2 letters (can also be blank), and must be in CAPS for US/Canada records. This rule also supports Canadian Provinces, which are also 2 letters and must also be in CAPS. But, we get membership requests from Europe where the State abbreviation is 3 letters like the one we got from Germany today which was NRW (North Rhein Westphalia), and so this rule in that case doesn't work:
AND( 
NOT(ISBLANK(MailingState)), 
OR( 
LEN(MailingState) <> 2, 
NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY:PR:" & "AB:BC:MB:NB:NL:NT:NU:ON:PE:QC:SK:YT", MailingState) 
)))

So I'm stuck as to what to do. Should I add this to the current rule?:
OR( 
LEN(MailingState) <> 3 

Let me know if anyone has a solution for this issue.

Thanks in advance.

Glenn
Hi,

I have created a custom button on the Opportunity object.  When clicked it runs a class which in turn starts off the approval process. 

This works fine in my developer sandbox but is not deploying due to code coverage issues.  I wonder if anyone can help, bearing in mind I have got as far as I can with some research as I am not a programmer and wanting to learn

Thanks

Class code with no coverage: -

global class Opportunity_Approval_to_PrepBid {

        public String myopi {get; set;}
        Webservice static String callApproval(String myopi) {

        Opportunity op = new Opportunity(Id=myopi);
        update op;

                Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitted for Approval');
                req1.setObjectId(myopi);
                Approval.ProcessResult res = Approval.Process(req1);   
                
                return null;
              
    }
}


Test class I tried: -

@IsTest

Public Class testApprovePrepare
 {
    static testMethod void testApprovePrepare()
    {
    
    Account a = new Account();
    a.Name ='demo';
    a.Industry = 'Education';
    a.BillingCountry = 'United Kingdom';
    insert a;
    
    Opportunity o = new Opportunity();
    o.AccountId = a.Id;
    o.StageName = 'Pipeline';
    o.Business_Unit__c = '1Spatial United Kingdom';
    o.Name = 'Test';
    o.Opportunity_Type__c = 'Contract Renewal';
    o.Contract_Type__c = 'Framework';
    o.Estimated_Value_Number__c = 10000;
    o.Opportunity_Submission_Date__c = Date.TODAY();
    o.CloseDate = Date.TODAY() +2;
    o.Probability__c = '80-99%';
    o.Purchase_Order__c = 'PO Pending';
    o.Solution_Summary__c = 'Hardware';
    o.Description = 'Renewal Contract for the next financial year';
    o.Opportunity_Process_Stage__c= 'Qualified Opportunity';
    insert o;
    
    Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitted for Approval');
                req1.setObjectId(o.Id);
                req1.setProcessDefinitionNameOrId('Auto_Approval_to_Prepare_Bid');
                Approval.ProcessResult res = Approval.Process(req1); 
                
                try{
            res = Approval.process(req1);
        }catch(Exception e){
            System.debug('No approval process has been setup yet.');


     }
}
}

Any help would be appreciated in getting this deployed to production

Many Thanks
Hello All,

We have an external application build on salesforce SDK that is connected to our salesforce organization. We would want to know how can we bypass the verification code pop up for certain set of users and directly login into the end users accounts ?

We tried by mentioning our IP address in trusted IP range but it still asks for a verification code. Note that we would want to bypass the verification pop-up only for 2-3 users only

Please advise.

Regards,
Neha Patil
I have 4 fields ranging in percentage and currency types (as shown below) that all will be required to contain a value prior to being saved. 

Can someone assist in creating the VR for this one? Thanks!

User-added image
Hi have a class that I am using to return dynamic information to the visualforce page. The error is happening at 
 
IF( MONTH( Date.today() ) == 5 )

Full Code
PUBLIC STRING getButton()
    {
        IF( MONTH( Date.today() ) == 5 )
        {
            theButton = 'Show: ';
            RETURN theButton;
        }
        ELSE
        {
            theButton = 'dont show';
            RETURN theButton;
        }
        RETURN null;
    }



 
I am using the NPSP and I am trying to write a select statement that will gather all of the events that are part of a single campaign.
I have come up with the following statement:
SELECT Name from GW_Volunteers__Volunteer_Job__c WHERE Campaign='701i00000010q96'

When I run this statement I recieve the following error:
PHP Fatal error:  Uncaught SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: 
GW_Volunteers__Volunteer_Job__c WHERE Campaign='701i00000010q96'
                                      ^
ERROR at Row:1:Column:56
No such column 'Campaign' on entity 'GW_Volunteers__Volunteer_Job__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. in C:\Sites\s2s\htdocs\salesForce\soapclient\SforceBaseClient.php:808
Stack trace:
#0 C:\Sites\s2s\htdocs\salesForce\soapclient\SforceBaseClient.php(808): SoapClient->__call('query', Array)
#1 C:\Sites\s2s\htdocs\salesForce\soapclient\SforceBaseClient.php(808): SforceSoapClient->query(Array)
#2 C:\Sites\s2s\htdocs\test.php(27): SforceBaseClient->query('SELECT Name fro...')
#3 {main}
  thrown in C:\Sites\s2s\htdocs\salesForce\soapclient\SforceBaseClient.php on line 808

When I look on the schema, it shows Campaign as part of the object, and from the research that I have done I know that I am allowed to view the campaign information. What exactly am I doing incorrectly?
Hi,

We have a certificate expiring in next 10 days in .sfa and production. We have installed new certificate in .sfa and planning to move it to production. How do we move the new certificate to production ? 

Hi everyone,
First of all i have a Lightning Component with associated an Application Light:Out. The App is inside a Visual Force page.

After click the quick action, a modal dialog shows my VisualForce.

In the controller of my Lightning Component at some point I fire this:
 

$A.get("e.force:closeQuickAction").fire();
But in the Visual force page, instead closing it, it shows this error:
This page has an error. You might just need to refresh it.
Error in $A.getCallback() [Cannot read property 'fire' of undefined]
Callback failed: apex://NextStepControllerLightning/ACTION$nextStepConfigurarion
Failing descriptor: {c:NextStepLightning}

This error doesn't show when i click on a quick action linked directly to the Lightning Component.
My goal is to close this modal dialog or instead manage the variables inside the controller of the component using function javascript inside my visual force. 

Thank you for help.
 
In Apex Test Result page, each test execution method history has a value of "Run Time", e.g. 283. Is it meaning it took 283 seconds to run this test method, or it is just  a reference without specific unit?


User-added image
Hello,
   I want to know about "DevOps AWS".

Your knowledge will be appreciating.

Thanks
Shephali
HI,

Can we write any Soql Query to fetch the newly created columns on any sobject on weekly basis?

Thanks  In Adavance!
public class Out 
{

    public Meta meta;
    public Response response;

    public class In1
    {
        public List<String> COMPANY;
        public List<String> SUCCESSFUL;
        public List<String> FUNDS;
        public List<String> FAILED;
    }

    public class IN2 
    {
        public Boolean successful;
        public String id;
        public In1 In1;
        public Integer number_of_resources_sent;
        public String access_token;
        public String uuid;
    }

    public class IN3 
    {
        public List<IN4> errors;
        public Integer status_code;
        public Integer version;
        public Double execution_time;
        public Integer timestamp;
    }

    public class IN4 
    {
        public String message;
        public String code;
    }

    public static Response parse(String json) 
    {
        return (Response) System.JSON.deserialize(json, Response.class);
    }
}
 
I have developed a custom Visual Force Page that requires me to have two possible paragraph elements. One paragraph is Risks/Issues and the other is Value Measurement. This is dependent on the Percent Complete field of the object. If the Percent Complete is 100, Risks/Issues is hidden else Value Measurement is hidden. Below is what I have so far and both paragraphs are showing instead of one. How can I fix this?

<div id="risks">
<div id="sh">
<p id="VZ">Risks/Issues</p>
<p id="VH">Value Measurement</p>
</div>
<script type="text/javascript">
if(Work_Item__c.Percent_Complete__c==100){
    $('#VZ').hide();
    }else{
    $('#VH').hide();}
</script>
 
Hai All

I have an requirement that when i enter account name in text box click on submit it display all the related contact records 
Please check my code

public class conbyacc {
    public String accname{set;get;}
    public list<Account> acclist{set;get;}
    public list<Contact> conlist{set;get;}
    public set<Account> accids{set;get;}
    public list<Contact> getcons(){
        acclist.clear();
        conlist.clear();
        accids.clear();
        acclist=[select Id,name from Account where name=:accname];
        for(Integer i=0; i<acclist.size(); i++){
            accids.add(acclist[i].Id);  // Getting Error
        }
        conlist=[select name,accountid from Contact where accountid IN:accids];
        return conlist;
        
    }

}


Thanks In Advance
Sampath Palli
Hi All,
I am getting "Unknown property 'VisualforceArrayList.Name" error while trying to create a Visualforce email template on custom object Status__c.
I have narrowed down the line that is actually giving me the error which is:
{!relatedTo.Demand_Vs_Supply_Master__r.Name}

I do not get this error when I change the line to display the ID instead of Name:
{!relatedTo.Demand_Vs_Supply_Master__c}

I have checked my relationship name is correct and cant figure out why it wont traverse to the related object.

Any help will be really appreciated.

Thank you!
 
<messaging:emailTemplate subject="{!relatedTo.Name} {!$Label.Incident_Submit_For_Approval}" 
recipientType="User" 
relatedToType="Status__c" 
language="{!recipient.LanguageLocaleKey}">
<messaging:htmlEmailBody >        
        <html>
            <body>
            <p>Hi {!relatedTo.Owner.Name},</p>
            <p>{!$Label.Incident_Submit_Approval_Request} {!relatedTo.Name}.</p>
            <p>{!relatedTo.Name} details :</p>
            
            <table cellspacing="0" cellpadding="0">
                <tr style="height: 21px;">
                    <td style="width: 130px;text-align: right;">Name</td>
                    <td style="padding-left: 10px;">{!relatedTo.Name}</td>
                </tr>                                             
                 <tr style="height: 21px;">
                    <td style="width: 130px;text-align: right;">Demand vs Supply</td>
                    <td style="padding-left: 10px;">{!relatedTo.Demand_Vs_Supply_Master__r.Name}</td>
                </tr>                                           
            </table>
            <p>You can either approve or reject by typing APPROVE or REJECT in the first line and adding comments in the second line in reply to this email.</p>
            <br/>Thank You,
            <!--<br/>{!relatedTo.Demand_Vs_Supply_Master__r.Supplier_Site__r.Site__r.Company__r.Name}.<br/>          -->
            </body>
        </html>
    </messaging:htmlEmailBody> 
</messaging:emailTemplate>



 
All,

I'm trying to call an apex function from a javascript button. I've read the developer guide and several relevant posts on this forum, but still can find out the issue. I have not created any namespace prefix for my dev org. The conroller is different from the Helper class with the web service method.
VF page:
<apex:page showHeader="false" >
  
 <script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
 <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
 
 <script type="text/javascript">
    
    function testRemote(){
        var id = sforce.apex.execute("HelperClass","getContactId",{});
        alert('id is: '+id);
        }
 
 </script>
  
 <div>  
    <button onclick="testRemote();">
      Remote
    </button>
  </div>
 </apex:page>

Apex class for webservice:
global class HelperClass {
    
    webService static String getContactId(){
       
        String id = '003j0000002CQ3B';
        return id;
    	}
}
Much appreciated,

Sarju
 
I get the error Invalid type: Approval.ProcessSubmitRequest when I have the statement 
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();

which I need to submit a request.  I don't understand why.  Even Salesforces own documentation show this way to create the object.  Any help?

 
Hi there!

I'm trying to test a apexrest api that I just built, but I can't seem to get past this error:
[{"message":"The HTTP entity body is required, but this request has no entity body.","errorCode":"JSON_PARSER_ERROR"}]

What exactly does this mean "The HTTP entity body is required, but this request has no entity body."? And how can I set the entity body in the request?

I've looked through almost all of the similar issues I found online and tried the solutions, but still nothing worked for me.

I'm using CURL to make this request:
curl -X POST 'https://myinstance.salesforce.com/services/apexrest/v1/MyRestApi?param1=value1&...' -H 'Content-Type: application/json' -H 'Content-Length: 0' -H 'Accept-type: application/json' -H 'Authorization:Bearer myaccesstoken'

And the apexrest code is:
@RestResource(urlMapping='/v1/MyRestApi/*')
global class MyRestApi {

	@HttpPost 
	global static void doPost(String param1, ...){
		
        map<String, Object> JSONResponseMap = (...);
        JSON.serialize(JSONResponseMap);        
        RestContext.response.responseBody = Blob.valueOf(JSON.serialize(JSONResponseMap));
		
	} 	  
}
If anyone has any idea of what's missing or what I am doing wrong, I would greatly appreciate some guidance!

Thanks in advance!
EF


 
We are running into a use case where an SFDC instance is at API v37 and when we try to use the batch API, we get a 404. When running the same request in non-batch mode, we get the record data. Is there any reason why this might be happening? Anything we can do to remedy?


Thanks!
Greg