• udayar_jayam
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 63
    Questions
  • 75
    Replies
I want to store key and value for the following json dynamically. 
Key as "01u9000000Ag0bbAAB" and value as "203"

String input = '[{"01u9000000Ag0bbAAB":"203","01u9000000Ag0bZAAR":"23","Id":"00k0w000003HeFhAAK"}]';


Please advise on this.
I'm using a single email message to send an email. When we tried to sent an email with a wrong email address on newly created lead record. I'm getting message result success is true. But the same record I have tried to send an email in the second time, I'm getting message result success is false. Please advice on this
List<Messaging.SingleEmailMessage> lstMassEmails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(toEmail);
email.setTargetObjectId(lstcountLead.id);
email.setTemplateId(templateId);
email.setSaveAsActivity(true);
lstMassEmails.add(email); 
Map<Id,Messaging.SendEmailResult> maptargetToResult = new Map<Id,Messaging.SendEmailResult>();
List<Messaging.SendEmailResult> sendEmailResults = Messaging.sendEmail(lstMassEmails,false);
Integer i=0; 
for(Messaging.SendEmailResult sendEmailResult: sendEmailResults){
    maptargetToResult.put(lstMassEmails.get(i).getTargetObjectId(),sendEmailResult);    
    i++;
}
System.debug('!!!maptargetToResult'+maptargetToResult);(First Time)
!!!maptargetToResult{00Qp00000050eh9EAA=Messaging.SendEmailResult[getErrors=();isSuccess=true;]}
System.debug('!!!maptargetToResult'+maptargetToResult);(Second Time)
!!!maptargetToResult{00Qp00000050eh9EAA=Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError
[getMessage=The target object email address is currently marked as bounced.;getStatusCode=EMAIL_ADDRESS_BOUNCED;getTargetObjectId=00Qp00000050eh9EAA;]);
isSuccess=false;]}

 
I am a user A with 'Force.com - App Subscription User' profile. I have created an Account 'Test Account' and made its Contact 'Test Contact' as a Partner User B. Now the account 'Partner Test' created by this Partner Account User B is visible to me. Though it is logical, my org security settings demand me not to see 'Partner Test' i.e., User A should not see Partner B's accounts. How can I make this restriction?

Account sharing setting: Private
Im Working on one scenario update description value in ContentDocument Object.
This my piece of code.
//Update Description value in ContentDocument object
        List<ContentDocument> lstcd = new List<ContentDocument>();
        for(ContentDocumentLink cdl: [SELECT Id, ContentDocument.Description, ContentDocumentId, ContentDocument.LatestPublishedVersionId FROM ContentDocumentLink WHERE LinkedEntityId = '500N0000002hZC9'])
        {
            ContentDocument cd = new ContentDocument();
            cd.id = cdl.ContentDocumentId;
            cd.Description = 'Testing';
            lstcd.add(cd);
        }

        update lstcd;
But im getting this Error: Compile Error: Field is not writeable: ContentDocument.Description

Please advise on this
We are currently working with Products and Pricebooks in Partner Community. The security side of it is still an idea in Salesforce but is there anyway we could restrict the Products visibility for Partners who are not supposed to view them?

Their Pricebook visibility is limited but they could still view Products of other Partners through Global Search. How do we restrict them from viewing? Currently we are thinking of overriding the branding header of Partner portal to limit visibility of the search box. Would there be a better solution for this?

Scenario:

Say we have Products(Prod1, Prod2, Prod3, Prod4, Prod5, Prod6).

Consider we have 2 Partners PartnerA and PartnerB. In this PartnerA need to see only (Prod1, Prod2, Prod3, Prod4) for PartnerB need to see only (Prod1, Prod2, Prod5, Prod6).

PartnerA should not see (Prod5, Prod6)

PartnerB should not see (Prod3, Prod4)

We tried this by creating 2 Pricebook(Pricebook1 and Pricebook2) for each Partners.

PartnerA has only access to Pricebook1.
PartnerB has only access to Pricebook2.

OWD setting:

Pricebook: No Access

After this, PartnerA can only see the product associated with Pricebook1 (Prod1, Prod2, Prod3, Prod4) in OpportunityLineItem. But the product (Prod5, Prod6) is still visible in Global search.

Is there any way to restrict these Product from Global Search or any workaround?
We tried to integrate the multiple signature to VF page, but we have some issue when we scroll the page for signature, the signature part not working properly. Can anyone please help me out in this?

<apex:page standardController="Lead" extensions="CustomerSignuporm" title="Customer Signup Form" sidebar="{!enableSFStd}" showHeader="{!enableSFStd}" standardStylesheets="{!enableSFStd}" renderas="{!rendermode}" applyHtmlTag="{!enableSFStd}">

    <style type="text/css">
        @page { size: 8.27in 11.69in; /* A4 width and height */ };
    </style>
    <apex:stylesheet value="//code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
    <apex:includeScript value="//code.jquery.com/jquery-2.1.1.min.js" />
    <apex:includeScript value="//code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js" />
    <script>var $j = jQuery.noConflict();</script>
    <apex:form >
        <apex:pageMessages />

        <apex:pageBlock rendered="{!NOT(enableSFStd)}">  
            <div style="width:100%;" >
                <div style="width:80%; margin:auto; border: 0px solid red">
                    <div id="header" style="height:30px;border: 0px solid blue">
                        <span>

                        </span>
                    </div>
                    <div id="body" >
                        <div id="personaldetailsection">
                           <!-- <div style="height:30px;border: 0px solid blue ;">
                                <span style="float:right"><b>PERSONAL DETAILS</b></span>
                            </div>-->
                            <div>
                                <div>


                                    <div style="height:30px; border: 0px solid blue;">
                                        <span>Applicant Signature</span>
                                    </div>
                                    <div style="height:30px; border: 0px solid blue;">
                                        <span>Applicant Signature</span>
                                    </div>
                                    <div style="height:30px; border: 0px solid blue;">
                                        <span>Applicant Signature</span>
                                    </div>
                                    <div style="height:30px; border: 0px solid blue;">
                                        <span>Applicant Signature</span>
                                    </div><div style="height:300px; border: 0px solid blue;">
                                        <span>Applicant Signature</span>
                                    </div>

                                    <!---------------Signature Section Starts ---------->
                                    <div style="padding-bottom: 10px; border: 0px solid blue;position:absolute;">                            
                                        <div id="signatureCaptureHome"  style="margin:0px 0 0 20px; " > 
                                            <div id="content">
                                                <apex:outputPanel rendered="{!signId == null}">
                                                    <canvas class="canvasElement" id="signatureCanvas" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas1" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas2" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas3" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas4" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas5" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas6" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas7" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas8" width="285" height="85" style= "border:2px solid #000" />
                                                    <canvas class="canvasElement" id="signatureCanvas9" width="285" height="85" style= "border:2px solid #000" />
                                                </apex:outputPanel>
                                                <apex:image id="image" url="/servlet/servlet.FileDownload?file={!signId}" rendered="{!signId != null}"/>
                                            </div> 
                                        </div> 
                                    </div>
                                    <!---------------Signature Section Ends ---------->
                                    <div>
                                        <div style="margin-left: auto; margin-right: auto; width: 200px;">
                                            <input id="saveSigButton" type="button" name="SigCap" onclick="CaptureSignature();" value="Submit Application" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="footer"></div>
                </div>
            </div>
            <apex:actionFunction action="{!savePDF}" name="savePDF"/>

        </apex:pageBlock> 
    </apex:form> 
    <apex:includeScript value="/soap/ajax/28.0/connection.js"/>         
    <script type="text/javascript">
        sforce.connection.sessionId = "{!$Api.Session_Id}";

        var isDrawing = false;
        var accountId = '';       

        function DrawingUtil(canvas) 
        {
            console.log("Inside DrawingUtil"+canvas);
            isDrawing = false;
            canvas.addEventListener("mousedown",start,false);
            canvas.addEventListener("mousemove",draw,false);
            canvas.addEventListener("mouseup",stop,false);
            canvas.addEventListener("touchstart",start,false);
            canvas.addEventListener("touchmove",draw,false);
            canvas.addEventListener("touchend",stop,false);
        }

        //Start Event for Signature Capture on HTML5 Canvas
        function start(event) 
        {
        event.preventDefault();
            console.log("Inside Start Event");
            isDrawing = true;
            canvas = document.getElementById(this.id);
            context = canvas.getContext("2d");    
            context.strokeStyle = "rgb(155,0,0,0.5)";      
            context.beginPath();
            context.moveTo(event.pageX - canvas.getBoundingClientRect().left,event.pageY - canvas.getBoundingClientRect().top);
            //context.moveTo(event.touches[0].pageX - canvas.getBoundingClientRect().left,event.touches[0].pageY - canvas.getBoundingClientRect().top);
        }
        //Event while someone is drawing to Capture the path while they draw....
        function draw(event) {
        event.preventDefault();
            console.log("Inside draw Event");

            event.preventDefault();
            if(isDrawing) {     
                //context.lineTo(event.touches[0].pageX - canvas.getBoundingClientRect().left,event.touches[0].pageY - canvas.getBoundingClientRect().top);
                context.lineTo(event.pageX - canvas.getBoundingClientRect().left,event.pageY - canvas.getBoundingClientRect().top);
                context.stroke();
            }
        }

        //Event when someone stops drawing their signature line
        function stop(event) {
        event.preventDefault();
            console.log("Inside stop Event");
            if(isDrawing) {
                context.stroke();
                context.closePath();

              isDrawing = false;  
            }
        }

        console.log("signatureCanvas");
        console.log(document.getElementById("signatureCanvas"));

        var canvasCollection = [];
        var canvas = [];
        var context = [];
        var drawingUtil = [];
        canvasCollection = getElementsByClassName('canvasElement');
        var canvasLength = canvasCollection.length;
        for(var j=0;j<canvasLength;j++)  { 
            canvas[j] = document.getElementById(canvasCollection[j].id);
            context[j] = canvas[j].getContext("2d");
            context[j].strokeStyle = "#4105F4";   
            drawingUtil[j] = new DrawingUtil(canvas[j]);
        }


        function CaptureSignature()
        { 
            var canvasNames = [];
            canvasNames = getElementsByClassName('canvasElement');
            var length = canvasNames.length;
            for(var j=0;j<length ;j++)  { 
                var canvas = document.getElementById(canvasNames[j].id);
                var strDataURI = canvas.toDataURL();
                strDataURI = strDataURI.replace(/^data:image\/(png|jpg);base64,/, "");
                CustomerSignuporm.Signature(strDataURI,'{!Lead.Id}',canvasNames[j].id,processResult);   
            }        
        }
        function processResult(result)
        {
            savePDF();
        }


    </script>

</apex:page>

global with Sharing Class CustomerSignupform
{
    public String rendermode { get; set; }
    public String recordId { get; set; }
    public String signId;    
    public Boolean enableSFStd { get; set; }    
    private Lead currentLead = new Lead();
    private Apexpages.StandardController controller;

    //Constants
    static final String SIGN_IMG_NAME = 'Sign.png';
    static final String PDF_NAME = 'SignForm.pdf';

    //Constructor Validate when page loads
    public CustomerSignuporm(Apexpages.StandardController stdCon) {
        controller = stdCon;
        enableSFStd = false;
        validatePage();
        getLeadDetails();
    }

    //Validate the page whether it has Lead Id or not
    //And also validate whether the signup form is already signed or not
    private Boolean validatePage() {
        // Check page has id parameters or not
        if (Apexpages.CurrentPage().getParameters().get('id') == null || Apexpages.CurrentPage().getParameters().get('id') == '') {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.WARNING,'Please select an Lead.');
            ApexPages.addMessage(msg);
            enableSFStd = true;
            return true;
        }
        recordId = Apexpages.CurrentPage().getParameters().get('id');

        //Check it is a valid Lead or not
        list<Lead> lstLead = [Select id,Name from Lead WHERE id =:recordID];
        if (lstLead.size() > 0) {             
            currentLead = lstLead[0];
        }
        else {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Customer not available');
            ApexPages.addMessage(msg);
            recordID = null;
            enableSFStd = true;
        }        

        //Set render mode to pdf if query string contains renderpdf
        if (Apexpages.CurrentPage().getParameters().get('renderpdf') != null) {
            rendermode = 'pdf';
        }
        return false;
    }
     public Void getLeadDetails()
    {
        Lead leaddetails = new Lead();
         User Owner = new User();
        recordID = ApexPages.CurrentPage().getparameters().get('id');
        System.debug(recordID);
        leaddetails = [SELECT id,SAP_Customer__c,OwnerId,NSL_Number__c
                FROM Lead WHERE id =:recordID];
                        /*****for email***************/        
        OwnerID = leaddetails.OwnerId;
        NslCustomer = leaddetails.NSL_Number__c; 
        Owner = [SELECT id, name, email FROM User WHERE id =:OwnerID];   
        email = Owner.Email;
        SalesExecutive = Owner.name;

    }
    //Remote Action to generate Signature as Attachment
    @RemoteAction
    global static String Signature(String signatureBody, String parentId,String signName) {
        try {
            //Delete Signature if already present
            deleteSignature(parentId);

            //Create New attachment for the Signature
            Attachment a = new Attachment();
            a.ParentId = parentId;
            a.Body = EncodingUtil.base64Decode(signatureBody);
            a.ContentType = 'image/png';
            a.Name = signName;
            insert a;
        }
        catch(Exception e) {
            system.debug('Create Signature Exception:' + e);
            //return JSON.serialize(e);
        }
        return null;
    }

    //After creating signature need to create PDF file for Customer Signup
    public PageReference savePDF() {

        PageReference pdf = Page.CustomerSignupform;
        pdf.getParameters().put('renderpdf', 'true');

        Boolean pdfGenerated = false;

        // create the PDF new attachment
        Attachment attach = new Attachment();
        Blob body;
        try {
            // returns the output of the page as a PDF
            body = pdf.getContentAsPDF();
            pdfGenerated = true;
        } 
        catch (Exception e) {
            body = Blob.valueOf('PDF generation failed');
        }

        attach.Body = body;
        attach.Name = ''+ NslCustomer+'_'+ DateTime.Now()+'.pdf'; // add the user entered name
        attach.IsPrivate = false;
        attach.ParentId = recordID;// attach the pdf to the Lead
        attach.ContentType='application/pdf';

        list<Lead> lstLead = [Select id from Lead WHERE id =:recordID];
        if (lstLead.size() > 0) {
            insert attach;


    // send the user to the account to view results
            deleteSignature(recordID);
            pdfGenerated = (pdfGenerated || Test.isRunningtest());
            if (pdfGenerated) {
                //Update Lead Record
                currentLead = lstLead[0];
                currentLead.Email_Complete__c = true;
                //currentLead.Signup_Form_Complete__c = true;
                update currentLead;
            }
        }

        // send the user to the Lead to view results
        return new PageReference('/'+recordID);

    }

    //Delete Signature from Attachment if it is present
    private static void deleteSignature(String parentId) {
        List<Attachment> lstAtch=[SELECT Id 
                                    FROM Attachment 
                                    WHERE Name=:SIGN_IMG_NAME 
                                        AND ParentId=:parentId
                                    LIMIT 1000];
        if(lstAtch.size()>0){
            delete lstAtch;
        }
    }

    //Returns Signature from Attachment if available
    public String getSignId() {
        List<Attachment> lst=[SELECT Id,Name,ParentId 
                                FROM Attachment 
                                WHERE Name=:SIGN_IMG_NAME 
                                    AND ParentId=:recordId];
        if(lst.size()>0) {
            signId=lst[0].id;
        }
        else {
            signId=null;
        }
        system.debug('signId'+signId);
        return signId;

    }
}

 
Hi All
we have a requirement to perform one contact with multiple Accounts scenario. To perform this logic I have a custom object called "Data Feed".We upload the data in that Data feed object periodically then what we need to do is we need to run the batch apex instantly to pass the Primary Id to Account Lookup under Contact object and at the same time we have to create one entry in Contact Role object by passing the Account ID. I am able to create "Contact" records using Batch Apex class.Its working fine .How can create a entry in Contact role as well at the same time.Please advice me on the same.

global class ScheduleContact implements Database.Batchable<SObject> {
global Database.queryLocator start(Database.BatchableContext ctx) {

    String query = 'Select Name,Account_ID__c,Primary_Account_ID__c, Deleted__c, First_Name__c, Internal_User_ID__c,Language_Preference__c,Language_Preference_Code__c,Phone__c,Primary_Contact__c,Speaks_English__c from Data_Feeds__c';


    return Database.getQueryLocator(query);

}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
    List<Data_Feeds__c> DFeedList = (List<Data_Feeds__c>)scope;


    List<Contact> conts = new List<Contact>();

    for (Data_Feeds__c d : DFeedList) {
        Contact cont = new Contact();
        cont.FirstName = d.First_Name__c;
        cont.LastName = d.Name;
        cont.AccountId= d.Primary_Account_ID__c;
        conts.add(cont);
    }

    insert conts;
}
global void finish(Database.BatchableContext BC) {

}
}
Hi All,
I am having two picklist field in VF Page.Based on the 2nd picklist value i need to make the 1st picklist field mandatory, which works fine.,but the issue is once i selected the value in 2nd picklist then the value in 1 st picklist changed, it is not displaying the value I already selected.How can solve this issues. Please let me know what am I doing wrong here

Piklist 1:
<apex:pageBlockSectionItem >  
    <apex:outputlabel value="{!$ObjectType.Case.fields.Is_booking_with_Primary_Freight__c.label}" for="Request"/>   
    <apex:outputPanel id="panel1">  
   <apex:inputField value="{!cases.Is_booking_with_Primary_Freight__c}"  required="{!if(reason == 'Rebook - Bring Booking Forward'||reason == 'Rebook - No Show'||reason == 'Rebook - Transport Company Issue'||reason == 'Rebook - Order was Rejected on initial delivery'||reason == 'Rebook - Vendor Issue'||reason == 'Rebook - BIG W Issue'||reason == 'Consolidate Orders',true,false) }"/>  
   </apex:outputPanel>  
    </apex:pageBlockSectionItem>

Picklist 2:
<apex:pageBlockSectionItem >    
  <apex:outputLabel value="Request Reason" />
  <apex:actionRegion >
  <apex:outputPanel styleClass="requiredInput" layout="block" id="pwPanel" >
   <apex:outputPanel styleClass="requiredBlock"/>
<apex:selectList id="Request_Reason" size="1" value="{!reason}"  label="Request Reason"  required="true" style="width: 155px; " >
     <apex:selectOptions value="{!reasons}" />    
     <apex:actionSupport event="onchange" reRender="panel1"  />    
  </apex:selectList>
</apex:outputPanel>
  </apex:actionRegion>
   </apex:pageBlockSectionItem>
Hi All
I have create a site for case creation,the case is created and show a success message when i hit backspace image button on browser its going back to orginal page.how can i prevent the user hit backspace button and browser in Sites. How can solve this issues.
Hi All
I have create a site for case creation,the case is created and show a success message when i hit backspace image button on browser its going back to orginal page.how can i prevent the user hit backspace button and browser in Sites. How can solve this issues.
Hi All,
I have two search criteria, one is for Account lookup it has to search in custom object based on the lookup selected value and other one is a text box which needs to enter the name. The user needs to search either using lookup value or text box value.I have one issue when i select the value form lookup and click the button it shows the values but the lookup field remains empty.I need to display the value after search in the lookup field.then only i will perform the validation part just like that.if(ship_partyNo=='' && AccountId=='' ){ run=false;ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please enter the value Name or PartyNo'));. }.guide me.

Public class sample_search
{
public List<sample_unit>Unt_sale{get;set;}
public string partyNo{get;set;}
public Boolean run{get;set;}
public Id AccountId;
public Account cont {get;set;}
public sample_search()
{
Unt_sale=new List<sample_unit>();
run=false;
}
public PageReference runQuery()
{
run=true;
try {
    cont=[select id, Name,ParentId  from Account where id=:cont.ParentId limit 1];  
}
catch(QueryException qe){
   // ApexPages.addMessage(ApexPages.Message(ApexPages.Severity.ERROR, qe.getMessage()));  
}
string queryunit='select id,name,subject__c,detail__c,Account__r.Id  from Units__c where name=:partyNo OR Account__r.ID =:AccountId';
process_unit(Database.query(queryunit)); 
}
private void process_unit(List<Units__c> unitsale)
{
Unt_sale.clear();
for(Units__c cu:unitsale)
{
Unt_sale.add(new sample_unit(cu));
}
}
//wrapper class for sample_unit
public with sharing class sample_unit
{
public Units__c unit{get;set;}
public sample_unit(Units__c unt)
{
unit=unt;
}
}
}

<apex:page controller="sample_search" >
<apex:pageBlock>
<apex:inputField value="{!cont.ParentId}">
<apex:inputText value="{!partyNo}"  id="accinfo1" />
<apex:commandButton value="Go" action="{!runQuery}">
</apex:pageBlock>
<apex:pageBlock rendered="{!run}">
   <apex:repeat value="{!Unt_sale}" var="us">
   <apex:outputField value="{!us.unit.Name}"/>
   <apex:outputField value="{!us.unit.subject__c}"/>
   <apex:outputField value="{!us.unit.detail__c}"/>
   </apex:repeat>  
</apex:pageBlock>
</apex:page>

 Hi All


 

I have a VF Page which displays the values from different object as a table. I need to perform the row based calculation in that table. Please find below the example and help me out in solving this

 

Rl R2 Total  Total(%)
A  25 25 50

B  50 75 125

I want to populate Account Number when the user click Account lookup field,but i got this error System.QueryException: List has no rows for assignment to SObject Error is in expression '{!AccountPopulated}' in page lookup_populate Class.Lookup_populate.AccountPopulated: line 8, column 1.

 

public class Lookup_populate{
public String AccNo{get;set;}
public Id AccountId;
public Account cont {get;set;}
public void AccountPopulated()
{
cont = new Account();
cont=[select AccountNumber from Account where id=:AccountId limit 1];
AccNo= cont.AccountNumber;
}
}

 

<apex:page controller="Lookup_populate" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection id="accinfo" title="Account Information">
<apex:actionRegion >
<apex:inputField value="{!cont.ParentId}">
<apex:actionSupport event="onchange" action="{!AccountPopulated}" rerender="accinfo"/>
</apex:inputField>
</apex:actionRegion>
<apex:inputText value="{!AccNo}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Hi All,

I have a VF Page to display two list named list1 and list2. In list1 i am having a picklist called "Status" which has two values named open and complete. In list1 if we select the picklist value "complete" then that record should move to list2. Here is my code but its not working , please guide me

 

public with sharing class sample {
public Integer numberOfRowToRemove1 { get; set; }
public List<Account> list1 { get; set; }
public List<Account> list2 { get; set; }
public string temp{get;set;}

public sampe()
{
list1 = [select id,name,accountnumber from Account];
list2 = [select id,name,accountnumber from Account];
}

public void find()
{

if(temp=='complete')
{
list2.add(0,list1.get(numberOfRowToRemove1));
list1.remove(numberOfRowToRemove1);

}

}
}
Page:
<apex:page controller="sample" >
<apex:variable value="{!0}" var="rowNumber1" />
<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber1" />
</apex:outputPanel>
<apex:pageBlock id="table1">
<apex:dataTable value="{!list1}" var="a" columnswidth="100px,100px" cellpadding="3" columns="4" border="1" width="1050px" bgcolor="#f5dcef" rowClasses="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" />
<apex:column value="{!a.AccountNumber}" headerValue="Number" width="100"/>
<apex:column headerClass="Status">
<apex:selectList id="selected_list" value="{!temp}" required="false" size="1">
<apex:selectOption itemvalue="None" itemLabel="--None--"/>
<apex:selectOption itemvalue="complete" itemLabel="complete"/>
<apex:selectOption itemvalue="Open" itemLabel="Open"/>
<apex:actionSupport event="onchange" reRender="Details,panelWithVar,table1,table2" action="{!find}"/>
<apex:param name="p1" value="{!rowNumber1}" assignTo="{!numberOfRowToRemove1}"/>
</apex:selectList>
<apex:variable var="rowNumber3" value="{!rowNumber1 + 1}" />
</apex:column>
</apex:dataTable>
</apex:pageBlock>

<apex:pageBlock id="Details">
<apex:pageBlockSection >
<apex:panelGroup >
<apex:dataTable value="{!list2}" var="a" columnswidth="50px,50px" cellpadding="4" border="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" width="100"/>
<apex:column value="{!a.AccountNumber}" headerValue="Address" width="100"/>
<apex:column headerClass="Status">
<apex:selectList id="selected_list" value="{!temp}" required="false" size="1">
<apex:selectOption itemvalue="None" itemLabel="--None--"/>
<apex:selectOption itemvalue="complete" itemLabel="complete"/>
<apex:selectOption itemvalue="Open" itemLabel="Open"/>
</apex:selectList>
</apex:column>
</apex:dataTable>
</apex:panelGroup>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

 

Hi All,

       For the first time i am doing integration.  Im having a consumer key and secret key of external system.Now I want to do initial connection between salesforce to external system using REST API, how to acheive this. Kindly give me any links and sample programs. I have seen the rest api documentation but i dont get any idea. Thanks in advance 

 Please guide me am i doing right  or wrong.i write a apex class and vf page but i getting this error  

 

Assertion Failed: System.HttpResponse[Status=Found, StatusCode=302]

Error is in expression '{!doRequest}' in component <apex:page> in page xerocontroller
 
Apex Class:

public class xeroController {

public String Headers {get; set;}
public String Response {get; set;}

public void doRequest() {
String data = '{'
+ '\n' + '"website":"https://api.xero.com/api.xro/2.0/",'
+ '\n' + '"segment":['
+ '\n' + ' {'
+ '\n' + ' "did":{'
+ '\n' + ' "operator":"AND",'
+ '\n' + ' "filters":['
+ '\n' + ' {'
+ '\n' + ' "scope":"actions",'
+ '\n' + ' "key":"name",'
+ '\n' + ' "match":"match",'
+ '\n' + ' "value":"quote"'
+ '\n' + ' }'
+ '\n' + ' ]'
+ '\n' + ' },'
+ '\n' + ' "are":{'
+ '\n' + ' "operator":"AND",'
+ '\n' + ' "filters":[]'
+ '\n' + ' }'
+ '\n' + ' }'
+ '\n' + '],'
+ '\n' + '"offset":0,'
+ '\n' + '"report_id":-1' +
'}';

System.HttpRequest request = new System.HttpRequest();
request.setBody(data);
request.setMethod('POST');
request.setEndpoint('https://api.xero.com/api.xro/2.0/');
request.setHeader('X-Api-Version', '2.0');
request.setHeader('X-Access-Id', 'UEOJMV6KBZKSD7VAWKHYLZ64TZSS9I ');
request.setHeader('X-Access-Secret', 'T6PVV8JMI3LV776V922OW3TR8OGY5L');

System.HttpResponse response = new System.Http().send(request);
System.assert(false, response); //remove this once you fix the 403
this.Response = response.getBody();
}
}

 

VF Page:

<apex:page controller="xeroController" action="{!doRequest}" contentType="text/plain">
  {!Headers}
  {!Response}
</apex:page>
              

Hi All,

       For the first time i am doing integration.  Im having a consumer key and secret key of external system.Now I want to do initial connection between salesforce to external system using REST API, how to acheive this. Kindly give me any links and sample programs. I have seen the rest api documentation but i dont get any idea. Thanks in advance 

Hi All,

      I trying to download program for contact object , the user click the "Download" custom button it should download all the records from the  object. This download file should in text format(.txt).when i download a file it display like this

johnkumarjane but i want to display like this in text file

john

kumar

jane

how to add break line in controller please anyone advice me.

public class contactquery{

    public List<Contact> cs{get; set;}
    public string empId;
    public contactquery() 
    {
    cs = new List<Contact>();
       for (Contact c : [Select id, Name from Contact ])
       {           
           cs.add(c);          
           
       }
       
    }
}



Vf Page:
<apex:page Controller="contactquery" contentType="text/plain/#emp.txt"  cache="true">
<apex:repeat value="{!cs}" var="contact">
<apex:outputText value="{!contact.Name}" escape="false"/><br/>
</apex:repeat>
 </apex:page>

 

 

Hi All,

          I trying to download program for custom object , we the user click the "Download" custom button it should download all the records from the custom object. This download file should in text format(.txt) with fixed width. Kindly anyone tell ideas and links for this. Thanks in advance

Hi All,

     How to integrate salesforce with xero using REST API.Please send me any links and guide me.

     Hi All,

                     I have Picklist value None,External,Internal,when i select none the Resource(percent) Fields remains zero or i select external and internal value ,the input value same what i entered in the Resource field.Based on the percentage value i need to calculate the total amount.How to solve this issues.

Hi All
I have create a site for case creation,the case is created and show a success message when i hit backspace image button on browser its going back to orginal page.how can i prevent the user hit backspace button and browser in Sites. How can solve this issues.
Hi All
I have create a site for case creation,the case is created and show a success message when i hit backspace image button on browser its going back to orginal page.how can i prevent the user hit backspace button and browser in Sites. How can solve this issues.
I have requirement to intregrate google map in visualforce page.i will fetch the address__c field which i need to show in google map from my custom object through controller. As I am new to salesforce, please help with code to implement it in my visualforce page.
  • July 05, 2014
  • Like
  • 0
Hi All
we have a requirement to perform one contact with multiple Accounts scenario. To perform this logic I have a custom object called "Data Feed".We upload the data in that Data feed object periodically then what we need to do is we need to run the batch apex instantly to pass the Primary Id to Account Lookup under Contact object and at the same time we have to create one entry in Contact Role object by passing the Account ID. I am able to create "Contact" records using Batch Apex class.Its working fine .How can create a entry in Contact role as well at the same time.Please advice me on the same.

global class ScheduleContact implements Database.Batchable<SObject> {
global Database.queryLocator start(Database.BatchableContext ctx) {

    String query = 'Select Name,Account_ID__c,Primary_Account_ID__c, Deleted__c, First_Name__c, Internal_User_ID__c,Language_Preference__c,Language_Preference_Code__c,Phone__c,Primary_Contact__c,Speaks_English__c from Data_Feeds__c';


    return Database.getQueryLocator(query);

}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
    List<Data_Feeds__c> DFeedList = (List<Data_Feeds__c>)scope;


    List<Contact> conts = new List<Contact>();

    for (Data_Feeds__c d : DFeedList) {
        Contact cont = new Contact();
        cont.FirstName = d.First_Name__c;
        cont.LastName = d.Name;
        cont.AccountId= d.Primary_Account_ID__c;
        conts.add(cont);
    }

    insert conts;
}
global void finish(Database.BatchableContext BC) {

}
}

I want to populate Account Number when the user click Account lookup field,but i got this error System.QueryException: List has no rows for assignment to SObject Error is in expression '{!AccountPopulated}' in page lookup_populate Class.Lookup_populate.AccountPopulated: line 8, column 1.

 

public class Lookup_populate{
public String AccNo{get;set;}
public Id AccountId;
public Account cont {get;set;}
public void AccountPopulated()
{
cont = new Account();
cont=[select AccountNumber from Account where id=:AccountId limit 1];
AccNo= cont.AccountNumber;
}
}

 

<apex:page controller="Lookup_populate" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection id="accinfo" title="Account Information">
<apex:actionRegion >
<apex:inputField value="{!cont.ParentId}">
<apex:actionSupport event="onchange" action="{!AccountPopulated}" rerender="accinfo"/>
</apex:inputField>
</apex:actionRegion>
<apex:inputText value="{!AccNo}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Hi All,

I have a VF Page to display two list named list1 and list2. In list1 i am having a picklist called "Status" which has two values named open and complete. In list1 if we select the picklist value "complete" then that record should move to list2. Here is my code but its not working , please guide me

 

public with sharing class sample {
public Integer numberOfRowToRemove1 { get; set; }
public List<Account> list1 { get; set; }
public List<Account> list2 { get; set; }
public string temp{get;set;}

public sampe()
{
list1 = [select id,name,accountnumber from Account];
list2 = [select id,name,accountnumber from Account];
}

public void find()
{

if(temp=='complete')
{
list2.add(0,list1.get(numberOfRowToRemove1));
list1.remove(numberOfRowToRemove1);

}

}
}
Page:
<apex:page controller="sample" >
<apex:variable value="{!0}" var="rowNumber1" />
<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber1" />
</apex:outputPanel>
<apex:pageBlock id="table1">
<apex:dataTable value="{!list1}" var="a" columnswidth="100px,100px" cellpadding="3" columns="4" border="1" width="1050px" bgcolor="#f5dcef" rowClasses="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" />
<apex:column value="{!a.AccountNumber}" headerValue="Number" width="100"/>
<apex:column headerClass="Status">
<apex:selectList id="selected_list" value="{!temp}" required="false" size="1">
<apex:selectOption itemvalue="None" itemLabel="--None--"/>
<apex:selectOption itemvalue="complete" itemLabel="complete"/>
<apex:selectOption itemvalue="Open" itemLabel="Open"/>
<apex:actionSupport event="onchange" reRender="Details,panelWithVar,table1,table2" action="{!find}"/>
<apex:param name="p1" value="{!rowNumber1}" assignTo="{!numberOfRowToRemove1}"/>
</apex:selectList>
<apex:variable var="rowNumber3" value="{!rowNumber1 + 1}" />
</apex:column>
</apex:dataTable>
</apex:pageBlock>

<apex:pageBlock id="Details">
<apex:pageBlockSection >
<apex:panelGroup >
<apex:dataTable value="{!list2}" var="a" columnswidth="50px,50px" cellpadding="4" border="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" width="100"/>
<apex:column value="{!a.AccountNumber}" headerValue="Address" width="100"/>
<apex:column headerClass="Status">
<apex:selectList id="selected_list" value="{!temp}" required="false" size="1">
<apex:selectOption itemvalue="None" itemLabel="--None--"/>
<apex:selectOption itemvalue="complete" itemLabel="complete"/>
<apex:selectOption itemvalue="Open" itemLabel="Open"/>
</apex:selectList>
</apex:column>
</apex:dataTable>
</apex:panelGroup>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

 

Hi,

 How to auto enable a field as required based on other fields input data in visual force

Can anyone please help.Its urgent.

 

Thanks in advance.

 

 

Hi All,

       For the first time i am doing integration.  Im having a consumer key and secret key of external system.Now I want to do initial connection between salesforce to external system using REST API, how to acheive this. Kindly give me any links and sample programs. I have seen the rest api documentation but i dont get any idea. Thanks in advance 

Hi Guys,

 

I need help with integrating Salesforce to Xero, an accounting software. I'm not sure where to start but if someone has tried integration with Quickbooks or other software, I will be open to suggestions. Thank you!

 

Regards,

 

Pfang

  • October 16, 2013
  • Like
  • 0

Hi All,

      I trying to download program for contact object , the user click the "Download" custom button it should download all the records from the  object. This download file should in text format(.txt).when i download a file it display like this

johnkumarjane but i want to display like this in text file

john

kumar

jane

how to add break line in controller please anyone advice me.

public class contactquery{

    public List<Contact> cs{get; set;}
    public string empId;
    public contactquery() 
    {
    cs = new List<Contact>();
       for (Contact c : [Select id, Name from Contact ])
       {           
           cs.add(c);          
           
       }
       
    }
}



Vf Page:
<apex:page Controller="contactquery" contentType="text/plain/#emp.txt"  cache="true">
<apex:repeat value="{!cs}" var="contact">
<apex:outputText value="{!contact.Name}" escape="false"/><br/>
</apex:repeat>
 </apex:page>

 

 

Hi All,

          I trying to download program for custom object , we the user click the "Download" custom button it should download all the records from the custom object. This download file should in text format(.txt) with fixed width. Kindly anyone tell ideas and links for this. Thanks in advance

Hi All,

     How to integrate salesforce with xero using REST API.Please send me any links and guide me.

Hi All,

      How to write apex class for to get dynamic url in any record and objects.

Hi All 

     I am trying to write a test class for this apex class and VF page but im getting this error 

System.NullPointerException: Attempt to de-reference a null objectStack TraceClass.Custom_Account_Lookup_Search.saveAccount: line 42, column 1
Class.Test_Custom_Account_Lookup_Search.test1: line 24, column 1

 how to solve this issue;

 

Test Class:

@isTest(Seealldata = true)
public class Test_Custom_Account_Lookup_Search
{
 Static testmethod void test1()
 {
    PageReference pg = page.Custom_Account_Lookup_Search_page;
    Test.setcurrentPage(pg);    
    //account a = new Account( name='foo' ,BillingStreet ='west',BillingCity ='test') ;
     //insert a;
     Account acc = new Account();
     acc.Name='voltum';
     acc.BillingStreet='Santhom High Road';
     acc.BillingCity='Chennai';
     acc.BillingState='TamilNadu';
     acc.BillingCountry='India';
     //acc.BillingZipPostal='6000028';
     acc.Email__c='perisoft@voltum.com';
     acc.Fax='+49 9134 85 28732';
     acc.Website='http://www.voltum.com.au/';
   insert acc;
     Site__c site = new Site__c();
     ApexPages.StandardController stdController1 = new ApexPages.StandardController(site); 
     Custom_Account_Lookup_Search thecontroller1 = new Custom_Account_Lookup_Search(stdController1);
     thecontroller1.saveAccount();
     
   }
}

 

Aex class:

public with sharing class Custom_Account_Lookup_Search {

public Account account {get;set;} // new account to create
public List<Account> results{get;set;} // search results
public string searchString{get;set;} // search keyword

public Custom_Account_Lookup_Search() {
account = new Account();
// get the current search string
searchString = System.currentPageReference().getParameters().get('lksrch');
runSearch();
}

// performs the keyword search
public PageReference search() {
runSearch();
return null;
}
public Custom_Account_Lookup_Search(ApexPages.StandardController stdController)
{
}
// prepare the query and issue the search command
private void runSearch() {
// TODO prepare query string for complex serarches & prevent injections
results = performSearch(searchString);
}

// run the search and return the records found.
private List<Account> performSearch(string searchString) {

String soql = 'select id, name from account';
if(searchString != '' && searchString != null)
soql = soql + ' where name LIKE \'%' + searchString +'%\'';
soql = soql + ' limit 25';
System.debug(soql);
return database.query(soql);

}

// save the new account record
public PageReference saveAccount() {
insert account;
// reset the account
account = new Account();
return null;
}

// used by the visualforce page to send the link to the right dom element
public string getFormTag() {
return System.currentPageReference().getParameters().get('frm');
}

// used by the visualforce page to send the link to the right dom element for the text box
public string getTextBox() {
return System.currentPageReference().getParameters().get('txt');
}

}

 

VF Page:

<apex:page controller="Custom_Account_Lookup_Search"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="pg">

<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

<!-- SEARCH TAB -->
<apex:tab label="Search" name="tab1" id="tabOne">

<apex:actionRegion >
<apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}" />
<span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
</apex:outputPanel>

<apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
<apex:pageBlock id="searchResults">
<apex:pageBlockTable value="{!results}" var="a" id="tblResults">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>

</apex:tab>

<!-- NEW ACCOUNT TAB -->
<apex:tab label="New Account" name="tab2" id="tabTwo">

<apex:pageBlock id="newAccount" title="New Account" >

<apex:pageBlockButtons >
<apex:commandButton action="{!saveAccount}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageMessages />

<apex:pageBlockSection columns="2">
<apex:repeat value="{!$ObjectType.Account.FieldSets.CustomAccountLookup}" var="f">
<apex:inputField value="{!Account[f]}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
</apex:page>