• Anil Malneni
  • NEWBIE
  • 38 Points
  • Member since 2015
  • Senior Consultant
  • Capgemini UK Plc

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 16
    Replies
Hello I am writing a test calss and I need create a quote object for testing purpose. However, quote(Detail) has a master-detail relarionship with opportunity object (Master). There fore when I wrote "Quote.Opportunity.Id=Opportunity.ID", it reports "Deference a NULL value " Error. Is there anyone know why is this happening and how to fix it? Any help is appreciated. 

Here are my codes:
Opportunity O = new Opportunity();
        O.Name='sss';
        O.AccountId=A.ID;
        O.LeadSource='Other';
        O.Type='New Business';
        O.CloseDate=myDate;
        O.StageName='Qualify';
        O.CurrencyIsoCode='CAD';
        
        Insert O;
        
        Quote Q=new Quote();
        Q.Name='TestQuote';
        Q.Status='Deaft';
        Q.Payment_Terms__c='Payment Schedule';
        Q.FOB__c='Our Shop';
        Q.Freight__c='Collect';
        Q.Lead_Time__c='TBA';
        Q.Email='liam@shaverinc.com';
        Q.ShippingState='ON';
        Q.Opportunity.Id=O.Id;
        Insert Q;

Thank you!
I would like to pre-populate the opportunity name and close date values on opportunity record creation. because these 2 fields are standard and required fields, which we can't remove from page layout.

My user's dont want to enter these fields on record creation...

Thanks in Advance....
I have move companies and want to move my badges to the new company. How do I move them so I do not loose all that work?

Is there a team thatyou can get a hold of to do that and if so how do I get a hold of them?

Thanks!
public class ContactExtcontroller {
public List<Contact> conlist{set;get;}

    public ContactExtcontroller(ApexPages.StandardSetController controller) {
    
conlist=[select id,lastname,firstname,phone,email from Contact];
    }

}
Here  I am getting error called"ContactExtcontroller Compile Error: Illegal assignment from List<Contact> to List<Contact> at line 6 column 1" 
Please help me anyone
Hi, Im new to triggers and apex and I need to update phone field (if blank) on contacts from the account field for existing records: 
Here is my try , but Im sure Im missing some elements. Any help is appreciated:

trigger updatephonefield on Contact (after update, after insert ) {
 for (Contact cp : Trigger.new) {
        if ( cp.Phone == null ) {
            cp.Phone == Account.Phone
            }
}
  • August 12, 2016
  • Like
  • 0
I am trying to be a Recall Button on the Quote Page:  I am receiving the error: A problem with the OnClick JavaScript for this button or link was encountered:  Unexpected Identifier.

Apex Class:
global class approvalRecall
{
    webservice static void recallApproval(Id recId)    
    {        
        List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
        req.setAction('Removed');        
        req.setWorkitemId(piwi.get(0).Id);
   
        Approval.process(req,false);
    }
}




{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 


var r = confirm("Are you sure want to recall the approval process?"); 
if(r == true) 

sforce.apex.execute("approvalRecall","recallApproval",{ID:"{!Quote.Id}"}); 
alert("Approval has been recalled"); 
window.open('/{!Quote.Id}'); 

else 

alert("Recall Cancelled"); 
}{!Quote.Id}
I have queue,See below screen.
User-added image

and in the queue i have role, now i need to get the users based on that role ,please help me
 I tried like below 
select Id, type from Group where type='Queue' AND Name='Customer Service Director'
and see the result below
User-added image
Select Id,UserOrGroupId,GroupId,Group.type,Group.relatedid From GroupMember where GroupId='QueueId'

User-added image
but in the queue i have role not group i am getting the Group id(Please check the prefix of userorGroupid ,it's staring with 00G(Prefix of group)).Please help me to get the Roles from Queue,thanks in advance.
 
Hello I am writing a test calss and I need create a quote object for testing purpose. However, quote(Detail) has a master-detail relarionship with opportunity object (Master). There fore when I wrote "Quote.Opportunity.Id=Opportunity.ID", it reports "Deference a NULL value " Error. Is there anyone know why is this happening and how to fix it? Any help is appreciated. 

Here are my codes:
Opportunity O = new Opportunity();
        O.Name='sss';
        O.AccountId=A.ID;
        O.LeadSource='Other';
        O.Type='New Business';
        O.CloseDate=myDate;
        O.StageName='Qualify';
        O.CurrencyIsoCode='CAD';
        
        Insert O;
        
        Quote Q=new Quote();
        Q.Name='TestQuote';
        Q.Status='Deaft';
        Q.Payment_Terms__c='Payment Schedule';
        Q.FOB__c='Our Shop';
        Q.Freight__c='Collect';
        Q.Lead_Time__c='TBA';
        Q.Email='liam@shaverinc.com';
        Q.ShippingState='ON';
        Q.Opportunity.Id=O.Id;
        Insert Q;

Thank you!
I have created a custom object with button for customized attachment related list on the Contact object. However, when I go to create the actual record and upload the file, the Contact name does not come through (should be in the "Back to" button seen below).

Error

Controller:
public class UploadAttachmentController {
    
    public String selectedType {get;set;}
    public Boolean selectedAwesomeness {get;set;}
    public String description {get;set;}
    private Contact contact {get;set;} 
    public String fileName {get;set;}
    public Blob fileBody {get;set;}
    
    public UploadAttachmentController(ApexPages.StandardController controller) { 
        this.contact = (Contact)controller.getRecord();
    }   
    
    // creates a new Contact_Attachment__c record
    private Database.SaveResult saveCustomAttachment() {
        Contact_Attachment__c obj = new Contact_Attachment__c();
        obj.contact__c = contact.Id; 
        obj.description__c = description;
        // fill out cust obj fields
        return Database.insert(obj);
    }
    
    // create an actual Attachment record with the Contact_Attachment__c as parent
    private Database.SaveResult saveStandardAttachment(Id parentId) {
        Database.SaveResult result;
        
        Attachment attachment = new Attachment();
        attachment.body = this.fileBody;
        attachment.name = this.fileName;
        attachment.parentId = parentId;
        // inser the attahcment
        result = Database.insert(attachment);
        // reset the file for the view state
        fileBody = Blob.valueOf(' ');
        return result;
    }
    
    /**
    * Upload process is:
    *  1. Insert new Contact_Attachment__c record
    *  2. Insert new Attachment with the new Contact_Attachment__c record as parent
    *  3. Update the Contact_Attachment__c record with the ID of the new Attachment
    **/
    public PageReference processUpload() {
        try {
            Database.SaveResult customAttachmentResult = saveCustomAttachment();
        
            if (customAttachmentResult == null || !customAttachmentResult.isSuccess()) {
                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 
                  'Could not save attachment.'));
                return null;
            }
        
            Database.SaveResult attachmentResult = saveStandardAttachment(customAttachmentResult.getId());
        
            if (attachmentResult == null || !attachmentResult.isSuccess()) {
                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 
                  'Could not save attachment.'));            
                return null;
            } else {
                // update the custom attachment record with some attachment info
                Contact_Attachment__c customAttachment = [select id from Contact_Attachment__c where id = :customAttachmentResult.getId()];
                customAttachment.name = this.fileName;
                customAttachment.Attachment__c = attachmentResult.getId();
                update customAttachment;
            }
        
        } catch (Exception e) {
            ApexPages.AddMessages(e);
            return null;
        }
        
        return new PageReference('/'+contact.Id);
    }
    
    public PageReference back() {
        return new PageReference('/'+contact.Id);
    }     

}

Visualforce Page:
<apex:page standardController="Contact" tabStyle="Contact" extensions="UploadAttachmentController">

<apex:sectionHeader title="{!Contact.Name}" subtitle="Attach File"/>

<apex:form id="form_Upload">
<apex:pageBlock >

<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Back to {!Contact.Name}"/>
 <apex:commandButton action="{!back}" value="Cancel"/>
 </apex:pageBlockButtons>
<apex:pageMessages />

 <apex:pageBlockSection columns="1">

<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file_File"/>
<apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
</apex:pageBlockSectionItem>

 <apex:pageBlockSectionItem >
 <apex:outputLabel value="Description" for="description"/>
 <apex:inputTextarea id="description" value="{!description}" rows="4" cols="50"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="" for="uploadBtn"/>
 <apex:commandButton id="uploadBtn" value="Attach File" action="{!processUpload}" />
 </apex:pageBlockSectionItem>

</apex:pageBlockSection>

 </apex:pageBlock>

 </apex:form>

</apex:page>
Hello,

I need your help about something strange on my sandbox:
I want to write a trigger that create one case for each opportunity line items when my opportunity is "Closed Won".
But I'm a junior developper so I started to write just the case creation when opportunity is "Closed Won". But I've got this error: 
Error: Compile Error: Variable does not exist: StageName ...
I think the trigger don't recognize all fields.
Please tell me what I'm doing wrong. Thanks
Here is my "simple" code :

trigger createNewCase on Opportunity (before insert, before update) {  
  
List<Case> listcase = new List<Case>();    
for(Opportunity o: Trigger.new)     
    {        
     
    if ( o.StageName == 'Closed Won' )                     
        {                    
        listCase.add(                
        new Case(                                          
        Priority = 'Medium',                
        Status = 'New'));        
        }    
    }    
        if(listcase.size()>0)     
            {        
            insert listcase;    
            }
}
Can anybody knows how should I handle single quote (apestrope) in below code?
OR(ISPICKVAL(Status,'In Progress- Engineering'),ISPICKVAL(Status,'In Progress- PLM's'))
I would like to pre-populate the opportunity name and close date values on opportunity record creation. because these 2 fields are standard and required fields, which we can't remove from page layout.

My user's dont want to enter these fields on record creation...

Thanks in Advance....
Hi All,

Earlier I had the Marketing Cloud Developer Edition. I used it for development of integration between Exacttarget and Salesforce. But right now my Developer Edition account is expired. I go to the https://code.exacttarget.com/developer-edition/ and see that Developer Edition is not available for registration at this time. How to receive Developer Edition account now ? Are there the alternative solution? Please advice!
Help please - I am trying to complete the Lightning Challenge here:

https://developer.salesforce.com/trailhead/lightning_components/lightning_components_creating

But when I submit I am told it is wrong:

The component does not include an H1 tag with a 'headline' CSS class

My component reads:

<!-- MyLightningComponent.cmp -->
<aura:component implements="force:appHostable"> 
    <div class="headline">
        <H1>Hello Lightning Component!</H1>
    </div>    
</aura:component>

and I have a Style:

.THIS {
    background-color: yellow;
    padding-top: 10px;
}

H1.THIS {
    font-size:24px;
}

.THIS H1{
    font-weight: bold;
    padding: 10px;
}

.THIS.headline {
    padding-top: 20px;
    font-size:24px;
}

.THIS .red {
    background-color: red;
    padding: 10px;
}

.THIS .blue {
    background-color: blue;
    padding: 10px;
}

.THIS .green {
    background-color: green;
    padding: 10px;
}

Can anyone describe what I have done wrong?