• anuragsinghns
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 14
    Replies

I would like to deserialize a parent into the child object I am not sure its possible but looking for advice.
Example:
opportunity opportunity =[select id,account.name from opportunity limit 1];
system.debug(json.serialize(opportunity));
this results in a string like this 
{"attributes":{"type":"Opportunity","url":"/services/data/v45.0/sobjects/Opportunity/0060D000002yQ5yQAE"},"Id":"0060D000002yQ5yQAE","AccountId":"0010D00000AdCKFQA3","RecordTypeId":"qwerty","Account":{"attributes":{"type":"Account","url":"/services/data/v45.0/sobjects/Account/0010D00000AdCKFQA3"},"Id":"00

 

when i try doing this 
opportunity opportunity =[select id,account.name from opportunity limit 1];
opportunity opportunity1 =(opportunity) json.deserialize(json.serialize(opportunity), opportunity.class) ;
system.debug('aa> '+opportunity1);

the opportunity fields are set but I see no account information in the debug.
 

Hi ,
I have a custom component and I have a button in the component it does not call the action emthod it is supposed to when clicked.

/My component /
<apex:component controller="myCOntroller" id="theComponent" allowDML="true">
<apex:commandButton value="Cancel" action="{!cancelDomain}" reRender="DomainSection" >
</apex:component>

/my contoller method/ 
public void cancelDomain() {
    system.debug('Test');
    }


I am unable to figure out why the action method does not get called any help would be appreciated.

Hi All,
I have an text  I am displaying based on a list size in my visualforce page.I an wondering if it is possible to dislpay a property in the apex code in the visualforce page.
callattemptList is my List based on wether it is empty or not  I want to display two different strings

<apex:pageBlock title="{!if(callattemptList.size>0,'!Username your tasks for the day','!Username not tasks found for you')}" id="theBlock" >
I need to pass the logged in username which is a propert in my apex code unable to find the right syntx for the same any help would be appreciated

hi guys,
I was wondering if there is a way I can write a query which would return me one value for a corresponding match in a list.
 Example say this is my set {'one','two','three'} lets call it mynameSet
and I write a query
list<account> myaccounts =[select id,Name from account where name=:mynameSet];

now in my system if I have 4 accounts like this below
                     Name
Account 1-  one
Account 2- two
Account 3- three
Account 4-  one

I want my query to return only three records not all 4 it should pick a either account1 or account4 I was also wondering if this is not possible to do so in a query what would be the best way to solve this issue without having the SOQL query return large amount of records.

 

Hi All,
I am using the chattter rest API to retreive file content stored in the File's object now(contentdocument) in salesforce in this case it's an image(jpeg).https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_files_content.htm
I am  facing a wierd issue here when I hit this resource " /chatter/files/fileId/content"  and i pass my fileId present in salesforce using SoapUI it gives me a base64encoded responsebody but when i use any of the available resources on the web to decode it and convert it back to an image (jpeg) the image is distorted so i decided to investigate further and base64encoded the image using one of the resources available on the web out there and compared it with the response salesforce is returning and to my suprise there were minor differences in the encoding hence the distortion not sure why this is happening any help here would be greatly appreciated.

Hi Guys,
facing a wierd issue I just completed a deployment to a sandbox and completed the run all tests it validated sucesfully and deployment went fine as well post which I went to the UI and did a run all tests to check the coverage and Suprise Suprise one of the test classes is failing (too many SOQL) my question is how is it that this class did not fail when I did my validation and deployment but it started failing post deployment any help here is appreciated
Hi Guys,
Pretty new to SoapUI so please help.
I have generated a WSDL from a Apex Class I have written.
If I try to Import to to SoapUI it gives the following error.

The Error:
: type 'address@http://soap.sforce.com/schemas/class/testclass' not found.

The Apex Class:

global class testclass {
    webService static List<Account> testquery() {
    list<account> selectedAccountList =[Select id,name from Account limit 10];   
    return selectedAccountList;
    }
    }
Hi Guys,
I need to access the State & Country Picklists values in my apex class any idea as to how this can be done I know it is available in API 31.0 onwards http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_addresssettings.htm

any help here will be really appreciated

Thanks
Hi Guys,
Working on Dynamic SOQL and I have created a query which shows up in the debug like this (I have printed only a part of the query).The calues in Bold are variables that are passed.So when I pass the Email Field and do a Database.Query I get the Following Error

Query:
FirstName =: singh  AND LastName =: odc AND PersonEmail =: odc@test.com)

Error:
|System.QueryException: expecting a right parentheses, found '@'

any help would be appreciated
Hi Guys,
I am getting this error when I tried to update a person account even though I am not mapping the name field on account I am just updating a address city field any thoughts?

//Assigning city to account field
updateAccount.PersonOtherCity=webCase.Home_City__c;

// updating the account
update accountsToUpdateLst;
Hi Guys,
I get Attempt to dereference a null object error with the system.debug below but if I comment it out the case gets created and also an account gets associated with it!Could you help me resolve this issue

//associating a account to the case
caseAccountPresent.accountId=accountUniqueIdMap.get(caseUniqueIdMap.get(caseAccountPresent)).Id; 
 //debug of the same
system.debug('the Account'+accountUniqueIdMap.get(caseUniqueIdMap.get(caseAccountPresent)).Id);
Hi I am writing a batch class to get all contacts where the EmailBouncedDate & EmailBouncedReason fields should be null.I am having a hard time saving because of the "!=" i am not bale to add the escape sequences correctly could anybody help as to where I am going wrong.

global class BouncedCaseCheck implements Database.Batchable<sObject> {
   public String query;
   global Database.QueryLocator start(Database.BatchableContext BC){
   query='SELECT EmailBouncedDate,EmailBouncedReason,Id FROM Contact'+'WHERE EmailBouncedDate !=\''+ null+'\''+'OR  EmailBouncedReason !=\''+null+'\'';
      return Database.getQueryLocator(query);
   }


Hi People,
I am trying to call an actionfunction on the onlick event of an output link and pass param values to the contoller is this possible?Currently it is not passing anything to the controller

My ActionFunction
<apex:actionFunction name="olla" action="{!testing}" >
<apex:param value="{!Name}" assignTo="{!accountName}" name="name" />
</apex:actionFunction>

My Link
<apex:outputLink onclick="olla('{!a.name}');return false;">{!a.name}</apex:outputLink>

I would like to deserialize a parent into the child object I am not sure its possible but looking for advice.
Example:
opportunity opportunity =[select id,account.name from opportunity limit 1];
system.debug(json.serialize(opportunity));
this results in a string like this 
{"attributes":{"type":"Opportunity","url":"/services/data/v45.0/sobjects/Opportunity/0060D000002yQ5yQAE"},"Id":"0060D000002yQ5yQAE","AccountId":"0010D00000AdCKFQA3","RecordTypeId":"qwerty","Account":{"attributes":{"type":"Account","url":"/services/data/v45.0/sobjects/Account/0010D00000AdCKFQA3"},"Id":"00

 

when i try doing this 
opportunity opportunity =[select id,account.name from opportunity limit 1];
opportunity opportunity1 =(opportunity) json.deserialize(json.serialize(opportunity), opportunity.class) ;
system.debug('aa> '+opportunity1);

the opportunity fields are set but I see no account information in the debug.
 

I used this code to unlock records after they enter approval process:

// Query the accounts to unlock
Account[] accts = [SELECT Id from Account WHERE Name LIKE 'Acme%'];
// Unlock the accounts
Approval.UnlockResult[] urList = Approval.unlock(accts, false);

// Iterate through each returned result
for(Approval.UnlockResult ur : urList) {
    if (ur.isSuccess()) {
        // Operation was successful, so get the ID of the record that was processed
        System.debug('Successfully unlocked account with ID: ' + ur.getId());
    }
    else {
        // Operation failed, so get all errors                
        for(Database.Error err : ur.getErrors()) {
            System.debug('The following error has occurred.');                    
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Account fields that affected this error: ' + err.getFields());
        }
    }
}

Using debug logs I can tell that it is unlocking the record when it is submitted for approval.  But in the UI it still has the unlock button and the record is locked.  So is the "Approval.unlock()" method used specifically to unlock the record only for apex users?  Does record lock itself again after all code run?  Is there something I can do to keep the record unlocked so a user can still edit it?
The thing is, it works on Admin Profile user but not on other Profiles, despite I get success in Approval.UnlockResult for both. I assume that the problem might be in permissions, anyone knows something regarding this issue?  Thanks
Hi All,
I have written a trigger on Order.
I am giving errors in two scenarios. I have one custom field Blocked__c in account. If I have blocked__c = Y, I dont want to create order.
This condition is not working properly.
This is my code. Please tell me where is bug
trigger orderTrigger on Order (before insert) {

List<Order> ordLs = [Select Id, F1__c,Status,AccountId,Account.Blocked__c from Order where createdDate=today ];  

for (Order ordNew : Trigger.new)
  {      
    for(Order oa: ordLs)
        {         
               if(oa.AccountId == ordNew.AccountId && oa.F1__c == ordNew.F1__c && oa.status == 'confirmed')         
                  {              
                    ordNew.AccountId.addError('Some messge');        
                  } 
               if(oa.Account.Blocked__c=='Y') {
                   ordNew.AccountId.addError('Blocked'); 
               } 
         }
        
  }

}

Please help me.
Line Number 13 is not working properly. Please suggest me changes.
Thanks in Advance
hi guys,
I was wondering if there is a way I can write a query which would return me one value for a corresponding match in a list.
 Example say this is my set {'one','two','three'} lets call it mynameSet
and I write a query
list<account> myaccounts =[select id,Name from account where name=:mynameSet];

now in my system if I have 4 accounts like this below
                     Name
Account 1-  one
Account 2- two
Account 3- three
Account 4-  one

I want my query to return only three records not all 4 it should pick a either account1 or account4 I was also wondering if this is not possible to do so in a query what would be the best way to solve this issue without having the SOQL query return large amount of records.

 
Hi all, 

I have a problem with this challenge :

Create a Queueable Apex class that inserts the same Contact for each Account for a specific state. Write unit tests that achieve 100% code coverage for the class.
Create an Apex class called 'AddPrimaryContact' that implements the Queueable interface.
Create a constructor for the class that accepts as its first argument a Contact sObject and a second argument as a string for the State abbreviation.
The execute method must query for a maximum of 200 Accounts with the BillingState specified by the State abbreviation passed into the constructor and insert the Contact sObject record associated to each Account. Look at the sObject clone() method.
Create an Apex test class called 'AddPrimaryContactTest'.
In the test class, insert 50 Account records for BillingState "NY" and 50 Account records for BillingState "CA". Create an instance of the AddPrimaryContact class, enqueue the job and assert that a Contact record was inserted for each of the 50 Accounts with the BillingState of "CA".
The unit tests must cover all lines of code included in the AddPrimaryContact class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.


I haven't 100% for my test class. 
 
@isTest
 public class AddPrimaryContactTest {
   
   
     @isTest static void TestList(){
         List<Account> Teste = new List <Account>();
         for(Integer i=0;i<50;i++){
             
             Teste.add(new Account(BillingState = 'CA', name = 'Test'+i));
         }
             for(Integer j=0;j<50;j++){
             
             Teste.add(new Account(BillingState = 'NY', name = 'Test'+j));
         
         }
         insert Teste;
         Contact co = new Contact();
          String state = 'CA';
     AddPrimaryContact apc = new AddPrimaryContact(co, state);
	Test.startTest();
	System.enqueueJob(apc);
     Test.stopTest();
         for (Account t:Teste){
             if( t.BillingState == 'CA'){
               	  
             	System.assertEquals(1, t.Number_of_contacts__c);
            
             
         }
         }      
}
 }
 
public class AddPrimaryContact implements Queueable{
    private Contact c;
    private String state;
    public  AddPrimaryContact(Contact c, String state){
        this.c = c;
        this.state = state;
        
    }
     public void execute(QueueableContext context) {
        List<Account> ListAccount = [SELECT ID, Name FROM ACCOUNT WHERE BillingState = :state LIMIT 200];
         for (Account l:ListAccount){
             for (Contact co:l.Contacts){
                 
                 c = co.clone(false,false,false,false);
                 insert c;
             }
                 
                 
             }
             
         }

}


Anyone can help me please?
Thanks!
Hi Guys,
facing a wierd issue I just completed a deployment to a sandbox and completed the run all tests it validated sucesfully and deployment went fine as well post which I went to the UI and did a run all tests to check the coverage and Suprise Suprise one of the test classes is failing (too many SOQL) my question is how is it that this class did not fail when I did my validation and deployment but it started failing post deployment any help here is appreciated
Hi,

I am having a requirement for which i need help


1) I am  having a text box and a custom button in my visualforce page which is creating a lead record

2) When i enter the values and hit the button a new case has to be created and atttached to the corresponding lead that is created

Help me how to do this

my controller:

public class AF_ScriptController {
  
    public String status {get;set;}
    public Lead_Object__c obj {get; set; }
    public Case caseRecord {get; set;}

   /**
   ** Constructor
   **/
   public AF_ScriptController (ApexPages.StandardController controller) {
 
      String newId = ApexPages.currentPage().getParameters().get('leadId');
      System.debug ('new Id *** :' + newId);

      if (newId != '') {
         obj = [Select Id,First_Name__c,Last_Name__c,Dealer_Type__c,Products_Dealership__c,F_I_Manager__c,Contracts_Electronically__c,Dealer_Track_RouteOne__c,What_percent_of_inventory_has_a_selling__c,What_percent_of_your_inventory_has_less__c,What_percent_of_your_inventory_is_newer__c,How_many_front_line_ready_units_do_you_c__c,What_are_your_average_monthly_used_vehic__c,Service_Department_on_site__c,Dealership_Retail__c,Dealership_Permanent_Building__c,Dealership_Payed__c,How_many_years_have_you_been_in_business__c,Leadstatus__c, test__c, salutation__c  from Lead_Object__c where id = :newId limit 1];
        
         if (obj.LeadStatus__c == 'Qualified' ) {
            System.debug ('Qualified *** : ' + status);
            status = System.Label.AF_QualifiedScript;
         }
         else {
            status = System.Label.AF_UnqualifiedScript;
            System.debug ('UnQualified *** :' + status);
         }
        
      
  
      }
     



   }
  
      public PageReference createNewCase(){

         Case cs = new case();
         cs.subject ='Lead Override Requested';
         insert cs;
       return new PageReference('/apex/AF_Flow?leadid=' + lead.id);

   }}


VF PAGE :


<apex:page standardController="Lead_Object__c" extensions="AF_ScriptController" >

<apex:pageBlock title="Comments Section" rendered="{!obj.Leadstatus__c == 'Unqualified'}">

          <b> <apex:outputLabel value="Lead Override Comments"  rendered="{!obj.Leadstatus__c == 'Unqualified'}" style="color:brown"/></b>

          <b> <apex:inputText   style="width: 270px; height: 100px;" required="true"/></b>

     <center> <b>  <apex:commandButton action="{!createNewCase}" value="Submit Lead Override" id="theButton"/></b></center>
      </apex:pageBlock>



Help me how to do this , am i doing wrong

Thanks in advance





    








Hi Guys,
Working on Dynamic SOQL and I have created a query which shows up in the debug like this (I have printed only a part of the query).The calues in Bold are variables that are passed.So when I pass the Email Field and do a Database.Query I get the Following Error

Query:
FirstName =: singh  AND LastName =: odc AND PersonEmail =: odc@test.com)

Error:
|System.QueryException: expecting a right parentheses, found '@'

any help would be appreciated
Hi Guys,
I am getting this error when I tried to update a person account even though I am not mapping the name field on account I am just updating a address city field any thoughts?

//Assigning city to account field
updateAccount.PersonOtherCity=webCase.Home_City__c;

// updating the account
update accountsToUpdateLst;
Hi Guys,
I get Attempt to dereference a null object error with the system.debug below but if I comment it out the case gets created and also an account gets associated with it!Could you help me resolve this issue

//associating a account to the case
caseAccountPresent.accountId=accountUniqueIdMap.get(caseUniqueIdMap.get(caseAccountPresent)).Id; 
 //debug of the same
system.debug('the Account'+accountUniqueIdMap.get(caseUniqueIdMap.get(caseAccountPresent)).Id);
Hi I am writing a batch class to get all contacts where the EmailBouncedDate & EmailBouncedReason fields should be null.I am having a hard time saving because of the "!=" i am not bale to add the escape sequences correctly could anybody help as to where I am going wrong.

global class BouncedCaseCheck implements Database.Batchable<sObject> {
   public String query;
   global Database.QueryLocator start(Database.BatchableContext BC){
   query='SELECT EmailBouncedDate,EmailBouncedReason,Id FROM Contact'+'WHERE EmailBouncedDate !=\''+ null+'\''+'OR  EmailBouncedReason !=\''+null+'\'';
      return Database.getQueryLocator(query);
   }


Hi People,
I am trying to call an actionfunction on the onlick event of an output link and pass param values to the contoller is this possible?Currently it is not passing anything to the controller

My ActionFunction
<apex:actionFunction name="olla" action="{!testing}" >
<apex:param value="{!Name}" assignTo="{!accountName}" name="name" />
</apex:actionFunction>

My Link
<apex:outputLink onclick="olla('{!a.name}');return false;">{!a.name}</apex:outputLink>