• Mohit Bansal6
  • NEWBIE
  • 305 Points
  • Member since 2015
  • Salesforce Evangelist
  • Tech9logy Creators


  • Chatter
    Feed
  • 10
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 82
    Replies
I have created a new Account Lookup field in Quotes. As soon as a user chooses that Account from Account Lookup, it should update AccountId on Opportunity with that lookup account. I created a trigger, but it does not seem to work. 
trigger updateOpptyAccount on Quote (before insert,before update) {
    for (Quote QuoteInLoop : Trigger.new){
        Boolean sMainAccount=QuoteInLoop.Main_Account__c;
        String sQuoteAccountId=QuoteInLoop.Pelco_Account_Name__c;
        String sOptyId=QuoteInLoop.OpportunityId;
        if(sMainAccount ){
            //QuoteInLoop.AccountId=sQuoteAccountId;
            List <Opportunity> Oppty1=[SELECT AccountId from Opportunity where Id = :sOptyId];
             Oppty1[0].AccountId=sQuoteAccountId;
            
        }
    }
}
I am a newbie, would appreciate any help/suggestion.
Hi,
I have a custom object named Service__c and it has a lookup with other object named Product__c. I want to create a button which allows me to add multiple products on the Product related list from Service object. This button should do what the "Add product" button from Order does(whitout that filter )
User-added image
I would like to conditionally hide few fields based on the value of a picklist. What I have is a picklist that shows the specific Account type. Based on that selection I would like to hide some fields so that I can enforce some level of process control.

I really appreciate your help in this regard.
Hi EVeryone,

Stumped on why i keep getting the following error when testing my code block: System.NullPointerException: Attempt to de-reference a null object
I understand the reason for the error, but cannot seem to figure out why the code is throwing it. the Feedback object should be initialized and be able to be added to the feedbackList.

Appreciate the help!
 
String d = 'a0G190000015uMg'; //for testing

//containers for querys
Deliverable__c deliverable;
List<Feedback_Survey_Question__c> questionList;
List<Feedback_Responses__c> responseList;
List<Feedback__c> feedbackList;
List<Approver__c> approverList;

//query db for lists
deliverable = [SELECT id, type__c, milestone__c, Number_of_Concepts__c, Status__c FROM Deliverable__c WHERE id = :d];
approverList = [SELECT id, name, Approver__c, Approver_Role__c FROM Approver__c WHERE Deliverable__r.id = :d];
//assign pieces of delvierable

decimal concepts = deliverable.Number_of_Concepts__c;
string milestone = deliverable.milestone__c;

System.debug(deliverable);
System.debug(concepts);
System.debug(milestone);

for (Integer i = 1; i <= concepts; i++){ 
    for (Approver__c a : approverList) { 
    
    String role = a.Approver_Role__c;
    String aid = a.id;
    
    Feedback__c Feedback = new Feedback__c();
    Feedback.Name = 'Concept ' + i;
    Feedback.Deliverable__c = d;
    Feedback.Approver__c = aid;
    feedbackList.add(Feedback); //ERROR BEING THROWN HERE
    
    }
    
}


 
Hello,

I made a new custom object called Produs (meaning Product). And I made a relationship between Produs and the standard object Opportunity.

After saving an opportunity, I want to have a related list below where I can add products (from the custom object Produs). I can just make new products, not add products already made in the Produs object.

Thanks!

User-added image

I am creating my first site. It will contain a single Visualforce page. The page is using a case field set. The page worked fine, I was able to access it throught the site url and test it's functionality. I added a new field to the field set, and I now get the generic, "Authoriziation Required" page when I navigate to the site url. I remove the field from the field set and can view the page as before.

My first thougth is that it's field level security around that field that is causing the problem. When I go to the field accessibility for the field in question, I see no entry for the site profile at all. I can find no other way to change field level security for that field, or even view what the accessibility is for my site profile. What am I missing? Or am I way off base?

Thanks,
Dan

Hi, I have this piece of code running. I'm trying to set the record type of a child object by using condition to look at a field value of parent.

Eg. Job division = content, Recordtype of work order = restoration.
       job division = other, Recordtype of work order = environmenta.

I have this in my pagereference but the parameter does not run correctly. I'm not sure how else should I be defining the parameters. 
 
public PageReference redirect(){
        
        String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix();
        String param = getParameters()+'&RecordType={!IF(Ispickval(Job_Number__c.Division__c,content),012Q00000000kxB,012Q00000000kxG)}';
        return new PageReference('/'+prefix+'/e?nooverride=1&'+param); 
    }

This is the error I'm getting:

Unable to Access Page
The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 

 
I have an text area field for the description of my case.
<apex:inputTextArea label="Description" value="{!Case.Description}" cols="120" rows="10" />

and for the view the output is as follows:
<apex:outputText label="Description" value="{!Case.Description}" style="word-wrap:break-word;white-space: normal" />

If I enter a lot of information with brakes or any type of formatting, after I save it, it turns into a one paragraph, no format at all.
I tried the word wrap CSS style, but still doing the same thing. Any ideas?
User-added image
Hi,
I have written Javascript to check all records using Checkbox, Plz see the snapUser-added image

Its working well but after a while it goes like below snap,

User-added image

My VF
<apex:page standardController="Payment__c" extensions="paymentController" id="page1">
<script>
function checkAll(cb,cbid)
{
    var inputElem = document.getElementsByTagName("input");                    
    for(var i=0; i<inputElem.length; i++)
    {            
        if(inputElem[i].id.indexOf(cbid)!=-1){                                       
        inputElem[i].checked = cb.checked;
        }
    }
}
function checkAll1(cb,cbid)
{
    var inputElem = document.getElementsByTagName("input");                    
    for(var i=0; i<inputElem.length; i++)
    {            
        if(inputElem[i].id.indexOf(cbid)!=-1){                                       
        inputElem[i].checked = cb.checked;
        }
    }
}
<apex:pageblockSection title="Payslip Selection" columns="1" rendered="{!paysec}" id="pb1s2">
            <apex:dataTable value="{!payslip}" var="pay" columnswidth="50px,50px" cellpadding="4" border="1" align="center" id="datatable">
                <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox >
                            <apex:actionSupport event="onclick" action="{!Getselected}" onsubmit="checkAll(this,'checkedone')" rerender="checkedone"/>
                        </apex:inputCheckbox>                  
                    </apex:facet>  
                    <apex:inputCheckbox value="{!pay.selected}" id="checkedone">
                        <apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS1"/>
                    </apex:inputCheckbox>
                </apex:column> 
                <apex:column headervalue="Payslip Name" value="{!pay.payslp.Name}" />
                <apex:column headervalue="VA Name" value="{!pay.payslp.Name__c}" />
                <apex:column headervalue="Bank Account" value="{!pay.payslp.Account_Number__c}"/>
                <apex:column headervalue="Bank Account" value="{!pay.payslp.Account_Number__c}"/>                
                <apex:column headervalue="Total Pay in Dollar" value="{!pay.payslp.Total_Pay_for_this_period__c}"/> 
                <apex:column headervalue="Total Pay in Peso" value="{!pay.payslp.Total_Pay_in_Peso__c}"/>                                        
            </apex:dataTable>
 </apex:pageblockSection>
Hope you can help,

Thanks.
 
here my Controller class

public class SalesOrder {
  public Order record{get;set;}
    public SalesOrder (ApexPages.standardcontroller std)
     { 
       record = new Order();           
     } 
  public pagereference dosave(){
      record.QuoteId = ApexPages.currentPage().getParameters().get('quoteID');
       insert record;
       ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
       pagereference page=new pagereference('/apex/SalesOrder');         
       return page;         
    }     
  public pageReference Cancel(){        
         pagereference page = new pageReference('/apex/QuoteVfPage');
         page.setRedirect(true);
         return page;
     }   
}
 here is test class

@istest
Private class TestSalesOrder{
    Static TestMethod void Dosave(){
        Test.startTest();
        
            PageReference pageRef = Page.SalesOrder;
            Test.setCurrentPageReference(pageRef);
            Account a=new Account(Name='test1',Phone='9458383336');   // creating account with only mandatory Fields
            insert a;
            Contact c = new Contact(LastName='Test',AccountId=a.Id);  // creating contact with only mandatory Fields
            insert c;
           // creating opportunity with only mandatory Fields
            Opportunity opp = new Opportunity(Name='Test Opp',AccountId=a.Id,StageName='closedwon',CloseDate=Date.Today());
            insert opp;
            // Creating Quote with only mandatory Fields
            Quote q=new Quote(Name='testquote',opportunityId=opp.Id);
            insert q;
            ApexPages.currentPage().getParameters().put('quoteID',q.Id );   
            Order ord = new Order(AccountId='a.Id',Name='test',status='draft',EffectiveDate=system.today());               
            Insert ord;
            ApexPages.standardcontroller std;
            SalesOrder sOrder = new SalesOrder(std);
            sOrder.dosave();
            sOrder.Cancel();
            
        Test.stopTest();
    }
    
    Static TestMethod void Cancel(){
        Test.StartTest();
        PageReference pageRef = Page.QuoteVfPage;
      Test.setCurrentPageReference(pageRef);
     }
}

when i am running my test class i am getting error 
My first AppExchange App:

Salesforce Bulk Object Field Creator app easily imports objects fields from CSV or XLS or XLSX file to Salesforce. It will help Salesforce Administrators and Developers to create upto 500 fields of 16 different field types in single go.


Bulk Object Field Creator

Below is the URL for AppExchange:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000qDqqEAE
 
Kindly share your feedback and suggestions for further advancements.

 
Regards
Mohit Bansal
Mobile:+91 995-317-0767
E-Mail: mishu67777@gmail.com
String queryString = 
                'SELECT Id  'FROM Account ' +
                'WHERE DISTANCE(GeoLocation__c, GEOLOCATION('+lat1+','+lon1+'), \'mi\') < ' + Integer.valueOf(SelectedWithin) ;

Here lat1, lon1, selectedWithin are the variables.

Can you help me in converting this dynamic query into direct query?
My first AppExchange App:

Salesforce Bulk Object Field Creator app easily imports objects fields from CSV or XLS or XLSX file to Salesforce. It will help Salesforce Administrators and Developers to create upto 500 fields of 16 different field types in single go.


Bulk Object Field Creator

Below is the URL for AppExchange:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000qDqqEAE
 
Kindly share your feedback and suggestions for further advancements.

 
Regards
Mohit Bansal
Mobile:+91 995-317-0767
E-Mail: mishu67777@gmail.com
I'm in the process of building a flow which includes the contact object. The object has 5 record types so I was hoping to show a screen where a user could select the type of record and then proceed to the next screen.

I can't seem to find any online material that could guide me through this. Does anyone have experience implementing this kind of solution?
i am having vf page and having 6 fields to select the fields are coming after selection of object then i have button called Query then according field selection we are getting selected object recrods then after this records i need to store in my cutom object how can i store can any one please help it it very urgent i and i am stuck on it..

please see below scrren shot of vf page with results 

User-added image
Hi,

VF-1:

apex:page controller="TwitterListApi" 
apex:form 
apex:pageBlock 
br/><br/> <h1
Please Press the button to get the List of Twitter Account Users
/h1><br/><br/
apex:commandLink value="Submit" action="{!Submit}" target="_blank" styleClass="btn"/
/apex:pageBlock
/apex:form
/apex:page

VF-2:

apex:page controller="TwitterListApi" showHeader="false" sidebar="false" action="{!generatecsv}" contentType="application/octet-stream#Twitter_Acoount Information.csv"
User Name, Name, Location, Mobile
apex:repeat value="{!Generate}"
{!screenname}, {!username}, {!location}, {!mobile}
/apex:repeat
/apex:page

Apex Code:

public class TwitterListApi
{
    public String oAuthConsumerKey = 'BlsoC839h5czptk6oHyyAgTGq';
    public String oAuthConsumerSecret = 'iAF4rc2AFEOP1h9rNVx4ZM8B86GXo4IGPcl2DN67iiMi6mdxnu';
    public String oAuthUrl = 'https://api.twitter.com/oauth2/token';
    public String oAuthUrl_1 = 'https://api.twitter.com/1.1/users/lookup.json?screen_name=';
    public String username{get;set;}
    public String location{get;set;}
    public String mobile{get;set;}
    public String screenname{get;set;}
    public String stoken;
    public List<Companies> list_com;
               
    public pageReference Submit()
    {
        pageReference pageRef= new pageReference('/apex/GenerateListApi');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public pageReference generatecsv()
    {
         String name;
        //List<String> list_name= new List<String>();
        List<username__c> list_user;
        try
        {
            list_user=[select name__c from username__c];
        }
        catch (System.QueryException e)
        {
            system.debug('Error in generatecsv method for list_user query** '+e);
        }
        for (username__c user:list_user)
        {  
           if (name==null)
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=url;               
           }
           else 
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=name+','+url;
           }
        }
        system.debug('name** '+name);
        //Encode them
        String keyencoded = EncodingUtil.urlEncode(oAuthConsumerKey, 'UTF-8');
        String secretkeyencoded = EncodingUtil.urlEncode(oAuthConsumerSecret, 'UTF-8');

        //Create Final Key String
        String sFinal = keyencoded + ':' + secretkeyencoded;
        //Convert to Blob
        Blob headerValue = Blob.valueOf(sFinal);
        system.debug('headerValue** '+headerValue);

        //Build Request
        HttpRequest req = new HttpRequest();
        req.setEndpoint(oAuthUrl);
        req.setMethod('POST');

        //Add Auth Header
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        system.debug('authorizationHeader** '+authorizationHeader);

        //You need to add this to the request - proved easy to miss in instructions...
        req.setBody('grant_type=client_credentials');

        //Make request
        Http http = new Http();
        try{
        HTTPResponse res = http.send(req);
        system.debug('Body_1** '+res.getBody());           

        //Parse JSON for Bearer Token
        
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken() != null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
        parser.nextToken();
        stoken = parser.getText();
        }
        }
        }
        catch(System.CalloutException e)
        {
            system.debug('Error_1** '+e.getMessage());
        }
     
    HttpRequest req2 = new HttpRequest();
    //I actually store the endpoint in the same custom setting and build dynamically, but for purposes of demo:
    req2.setEndpoint(oAuthUrl_1 + name);
    req2.setMethod('GET');

    //Call Bearer token Method
    //Note - unless invalidated, I believe you can store this and keep using it indefinitely, but again, to demo concept
    String authorizationHeader_1 = 'Bearer ' + stoken;
    req2.setHeader('Authorization', authorizationHeader_1);
    system.debug('authorizationHeader_1** '+ authorizationHeader_1);

    try{
    HTTPResponse res = http.send(req2);
    String sBody = res.getBody();
    system.debug('Body_2** ' + sBody);
    boolean success=true;
    
    JSONParser parser=JSON.createparser(res.getBody());
    while (parser.nextToken()!=null)
    {
        if(parser.getCurrentToken()== JSONToken.START_OBJECT)
        {    
            while (parser.nextToken()!=null)
            {
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='screen_name'))
                {
                    parser.nextToken();
                    screenname=parser.getText();
                    system.debug('screenname** '+screenname);
                    success=true;
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='name')) 
                {
                    parser.nextToken();
                    username=parser.getText();
                    system.debug('username** '+username);
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='location'))
                {
                    parser.nextToken();
                    location=parser.getText();
                    location = '"'+location+'"';
                    system.debug('location** '+location );
                }
                
                if (success)
                {
                    if ((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='description'))
                    {
                        parser.nextToken();
                        mobile=parser.getText();
                        success=false;
                        system.debug('mobile** '+mobile);
                        List<Companies> list_com=new List<Companies>();
                        Companies com=new Companies(screenname, username, location, mobile);
                        system.debug('com** '+com);
                        list_com.add(com);
                        system.debug('list_com-1** '+list_com);
                    }
                 }
                 
            }
        }
    }
    }
    catch(System.CalloutException e)
    {
        system.debug('Error_2** '+e.getMessage());
    }
        return null;
    }
    
    public List<Companies> getGenerate()
    {
            system.debug('list_com** '+list_com);
            return list_com;
    }
    
    public class Companies
    {
        String screenname;
        String username;
        String location;
        String mobile;
        
        public  Companies(String screename, String username, String location, String mobile)
        {
             this.screenname=screenname;
             this.username=username;
             this.location=location;
             this.mobile=mobile;   
        }
    }
}
vf page:
apex:pageBlockTable value="{!Opportunity}" var="op" align="center" style="border:none;"
              
              apex:column 
              
                   apex:outputPanel rendered="{!IF(CONTAINS(mapKey,op.name)=True,False,True)}"  
                       apex:commandButton value="Add to LY Prospect List" action="{!show}" rerender="popup" onclick="this.style.visibility = 'hidden' "
                             apex:param name="OppName" value="{!op.id}" assignTo="{!opid}"/
                       /apex:commandButton
                   /apex:OutputPanel

Apex Page:

public string mapkey;

       for(Companies com: compList){
            if(MrktRatngMap.containsKey(com.ComName)==True){
            mapKey=mapKey+' '+com.ComName;

             }
     }

Q Please let me know the meaning of the statement: apex:outputPanel rendered="{!IF(CONTAINS(mapKey,op.name)=True,False,True)}"  
Need help, I'm in the Force.com IDE. I have deleted the calss in the sandbox, but will not delete in production. 

Class Names: CloneListTest 

Error 1:  test coverage across all Apex Classes and Triggers is 72%, at least 75% test coverage is required.    Tremor Video Production        line 1    Force.com code coverage warning

Error 2:  System.NullPointerException: Attempt to de-reference a null object    CloneListTest.cls    /Tremor Video Production/src/classes    line 56    Force.com run test failure
Hello, I have a survey returned where the customer was mixed up on the scale of the reponses.  I would like to change the survey results that were returned.
Anyone know how I would do this ?

Thanks.

Mike.
trigger UsableUpdateTrigger on EFX_WorkItem__c (after insert, after update, after delete) {
for (EFX_WorkItem__c w: trigger.new) {
if(Trigger.isUpdate){
    EFX_WorkItem__c recordIdOfParent = [SELECT recordTypeid FROM EFX_WorkItem__c WHERE Parent_Item__c =:w.Parent_Item__c limit 1];
    RecordType idLevel0 = [Select Id From RecordType Where Name ='Level 0 Task' limit 1];
    RecordType idLevel1 = [Select Id From RecordType Where Name ='Level 1 Task' limit 1];
    RecordType idLevel2 = [Select Id From RecordType Where Name ='Level 2 Task' limit 1];
    RecordType idLevel3 = [Select Id From RecordType Where Name ='Level 3 Task' limit 1];
    if(recordIdOfParent!=null){
        if(recordIdOfParent.recordTypeid == idLevel3.Id){
        }else if(recordIdOfParent.recordTypeid  == idLevel2.Id){
            w.recordTypeid = idLevel3.Id;  //record is read only
        }else if(recordIdOfParent.recordTypeid  == idLevel1.Id){
            w.recordTypeid = idLevel2.Id;
        }else if(recordIdOfParent.recordTypeid  == idLevel0.Id){
            w.recordTypeid = idLevel1.Id;
        }
        update w;
    }
}
}
Hello,

My custom object has few columns,
When i try to reset recordTypeid t gives me //record is read only

I dont know the cause for this error.

I am able to update other rows with other fields.

I have trouble in updating current row with column recordTypeid 
I have created a new Account Lookup field in Quotes. As soon as a user chooses that Account from Account Lookup, it should update AccountId on Opportunity with that lookup account. I created a trigger, but it does not seem to work. 
trigger updateOpptyAccount on Quote (before insert,before update) {
    for (Quote QuoteInLoop : Trigger.new){
        Boolean sMainAccount=QuoteInLoop.Main_Account__c;
        String sQuoteAccountId=QuoteInLoop.Pelco_Account_Name__c;
        String sOptyId=QuoteInLoop.OpportunityId;
        if(sMainAccount ){
            //QuoteInLoop.AccountId=sQuoteAccountId;
            List <Opportunity> Oppty1=[SELECT AccountId from Opportunity where Id = :sOptyId];
             Oppty1[0].AccountId=sQuoteAccountId;
            
        }
    }
}
I am a newbie, would appreciate any help/suggestion.
Hi,

I add a new visualforce page to add new opportunities.
That works fine, but I want that the fields StageName and Probability are in dependency.
These fields are the standardfields from the object opportunity and it works if I use the standardopportunity case in salesforce.
If I change the StageName should change also the Probability.

Thanks,
Sascha
<apex:pageblock title="Verkaufschance Übersicht" id="pbOpp" mode="inlineEdit">
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!SaveNewOpp}" value="Save" id="saveButton1" rerender="pbOpp" rendered="{!IF(newOpp=1,true,false)}"/>
        <apex:commandButton action="{!CancelNewOpp}" value="Cancel" id="cancelButton1" immediate="true" rendered="{!IF(newOpp=1,true,false)}"/>
    </apex:pageBlockButtons>              
    <apex:pageBlockSection rendered="{!IF(newOpp=1,true,false)}" columns="2">
        <apex:inputField value="{!oppString.RecordTypeId}"/>    
        <apex:inputField value="{!oppString.Name}"/>
        <apex:inputField value="{!oppString.StageName}"/>        
        <apex:inputField value="{!oppString.Amount}"/>
        <apex:inputField value="{!oppString.Probability}"/>
        <apex:inputField value="{!oppString.Bewertung_in__c}"/>
        <apex:inputField value="{!oppString.CloseDate}"/>
    </apex:pageBlockSection>
</apex:pageBlock>

 
I am getting an error when I tried to insert more than 200 account records using data loader. I created the below trigger code and the error message is shown below. any idea guys?

oppCreate: execution of AfterInsert

caused by: System.DmlException: Insert failed. First exception on row 0 with id 00628000002gPTkAAM; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Trigger.oppCreate: line 19, column 1



trigger oppCreate on Account (after insert) {

List<Opportunity> newlyCreatedOpp =  new List<Opportunity>();

for (Account newAcc : Trigger.new)
{

Opportunity createOpp = new Opportunity ();
    createOpp.Name = newAcc.name + 'Opportunity';
    createOpp.CloseDate = system.today().addDays(30);
    createOpp.AccountId = newAcc.Id;
    if (newAcc.numberofEmployees> 100) {
    createOpp.StageName = 'Prospecting'; } 
    else if(newAcc.numberofEmployees< 100) {
    createOpp.StageName = 'Qualification'; }
    else {}
    
newlyCreatedOpp.add(createOpp);

    }
      
insert newlyCreatedOpp;


}
Hi All,

Below is my code:

VF Page:

<apex:page controller="SummaryPdfDispController" standardStylesheets="false" showHeader="false" sidebar="false">


<apex:form >
     <apex:pageBlock Id="status1">

<apex:commandLink action="{!SendEmail}" value="Email Dossier" reRender="status1" styleClass="element" onclick="this.value = 'Sending...'"/>
    </apex:pageBlock>
</apex:form>
</apex:page>

Note:
1. If I omit the onclick functionality then action- SendEmail is called.
2. I could not use commandbutton as per project purpose.
3. I have used javascript on onclick functionality, but it did not work.

 
Wrote a trigger to change the record type after a field getting populated in the same object. Its getting saved, but not working.

trigger RecordTypeMap on Case (before insert) {

Map<Id, String> typeMap = New Map<Id, String>();
for(RecordType rt: [Select DeveloperName, Id From RecordType Where sObjectType = 'Case']) {
     typeMap.put(rt.Id,rt.DeveloperName);
   }

 for (Case cc : trigger.new)  {

      
      if (cc.Master_Record_Type__c != null) { 
            
               id recid = typeMap.get(cc.Master_Record_Type__c);
               recordtype rectype = [select id, developername from recordtype where id=:recid];
               cc.RecordTypeid = rectype.id; 
              
            }
       }
   }
Hii All,
Actually i need to get attachment consisting of listof contact names,phone,mailingcity from inbound mail (i.e.,email services) and need to generate records from that attachment automatically. I have an apex class regarding getting attachment from inbound mail. But not able to retrieve records from attachment. Can anyone help in this?

Here is the code


global class ContactEmailservice implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

    Contact contact = new Contact();
    contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
    contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
    contact.Email = envelope.fromAddress;
       
    insert contact;

    System.debug('====> Created contact '+contact.Id);

    Attachment attachment = new Attachment();
    attachment.ParentId = contact.Id;
    attachment.Name = email.subject;
    attachment.Body = Blob.valueOf(email.HtmlBody);
    insert attachment;
    return result;
  }
}
Hello,

Currently in our org there are many batch jobs which run and perform certain activities. Now the requirement is to notify the admin immediately via email when any of the batch jobs is failed . Though I know, there is a mail template which can be implemented in finish method of each batch job, however it is difficult to put in every batch jobs as it is time consuming.

Could you please help in getting a common class which will check what are the batch jobs that finish the run for a particular day(ideally every day) and then for failed jobs it will send immediate email notification?
Hi

I want to read Email Inbound attachment file  in apex class and create new object's records.
Since the file is in ANSI Format it is considered as binary attachment even if the file is a text file.

I want to read the body of the file.

I have checked that Apex Class version 19.0  can able to read the Blob by Blob.toString() method, but greater version cannot able to read. It is throwing exception as "BLOB is not a valid UTF-8 string".

I want to use ANSI file foramt as attachment since these files are coming from different system automatically.

Please help me to read out the content of email inbound attachment file.

Hi, I need to delete 100+ fields in one custom object, what is the best way to do this?

 

Does Eclipse support field deletion?

 

Thanks.