• asish1989
  • SMARTIE
  • 1949 Points
  • Member since 2011
  • System Engineer
  • TCS

  • Chatter
    Feed
  • 65
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 515
    Replies
Hi folks, 
       Can anyone tell me how to display the account details using Visualforce Remoting

Thanks in advance
I am trying to build a button in the list view to:
Change case ownership to the current user
Change the case status to work in progress

I have the following code in the detail page that works fine:

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var caseObj = new sforce.SObject("Case");

caseObj.Id = '{!Case.Id}';

caseObj.OwnerId = '{!$User.Id}';

caseObj.Status = "Work In Progress";

var result = sforce.connection.update([caseObj]);

window.location.href=window.location.href;

but when I put the button in the list view and click on the button, nothing happens.
it is configured to execute java script as behavior and contentsouce is set to on clickjavascript

Could you guys please provide me some light?
what are apex web services and callouts ,http request ?

i tried goin thru links bt couldnt undstnd ,  dnt post links
pls xplain in general terms so that i can hv a clear understanding of these.
this is my trigger   here "msport__c "is my child  nd "mstudent__c" is my parent


trigger GetOwner on MSport__c (Before insert, Before update)
{
    set<id> set1=new set<id>();
    map<id,string> map1=new map<id,string>();
    list<user> userlist=new list<user>();
    if(trigger.isBefore)
    {
        if(trigger.isinsert || trigger.isUpdate)
        {
            for(MSport__c sp:trigger.new)
            {
                set1.add(sp.MStudent__r.ownerid);
            }
            if(set1.size()>0 && set1!=null)
            {
                userlist=[select id,name from user where id in: set1];
                for(user u:userlist)
                {
                    map1.put(u.id,u.name);
                }
                if(map1.size()>0 && map1!=null)
                {
                    for(MSport__c s:trigger.new)
                    {
                        s.Owner__c=map1.get(s.MStudent__r.ownerid);
                      
                    }
                }
            }
        }
    }

}
Hi,

I have written a controller fro my visualforce page. The vf page is created for when an account is selected using the checkbox, an opportunity should be created with the same name as the account. I have written a controller for this purpose. But I get only 69% code coverage for this controller. Can anyone suggest a solution?

My Controller code is:

/*************************************************************************************************
Created By: Anju Alexander
Created Date: 19/8/14
Version: 31.0
Description: Controller class to create opputunity with the same name as the account selected
**************************************************************************************************/


public class opp{
public boolean s;
public List<AccountWrapper> wrapAccountList {get; set;}
/*************************************************************
List that contains all the accounts
**************************************************************/

List<Account> Aaccount=[select name,phone,industry from Account];
public AccountWrapper accountWrapper1=new AccountWrapper();

/*************************************************************
Method to set the instances of the wrapper class'AccountWrapper'
**************************************************************/
public opp()
{
            wrapAccountList = new List<AccountWrapper>();
            for(Account a: Aaccount)
            {
            wrapAccountList.add(new AccountWrapper(a,s));
            }
       
}
/*************************************************************
Method to create opportunity when the accounts are selected
**************************************************************/


public pageReference createOpp()
{

        for(AccountWrapper wrapObj : wrapAccountList) {
            if(wrapObj.selected == true)
            {
                Opportunity opportunity1= new Opportunity();
                String accountName=wrapObj.AccountInstance.name;
                opportunity1.name=accountName;
                opportunity1.closedate=date.today();
                opportunity1.stagename='Prospecting';
                insert opportunity1;
            }
        }
PageReference pg= new PageReference('https://ap1.salesforce.com/home/home.jsp');
pg.setRedirect(true);
return pg;
}
/*************************************************************
Wrapper class to contain Account Instance and selected value
**************************************************************/
public class AccountWrapper
{
        public Boolean selected{get;set;}
        public Account AccountInstance{get;set;}
        public AccountWrapper(Account a,Boolean s)
        {
        AccountInstance=a;
        selected=false;
        }
          public AccountWrapper()
        {
       
        }
}
}
want to update a autonumber field from a another custom formula field of sam object..
here name is autonumer field and Program_Name__c is formula field.. when i create a record i need to update name field by Program_Name__c field...
pl help me

trigger updatename on Course_Program__c (after insert, after update) {

for(Course_Program__c cp: trigger.new)
{
if(cp.Program_Name__c != null)
{
cp.name=cp.Program_Name__c;

}
}
}

getting error:Field is not writeable: Course_Program__c.Name at line 7 column 1
Hi,

Could you please help me to create a  VF page.
I am looking for a help in repeating certains fields under an object by clicking an button (+ or Add). For ex: we have 3 fields:

1) Quantity - Number field
2) Product - Pick List field
3) Version - Number field

We would like these three fields to repeat upon a click of button like + or Add, so that we can enter as many data according to our requirement.

Any help will be highly appreciated.

Thank You,
Mithun
Hi, 

I am trying to replicate Contact EditDetail page with my visualforce page.

Here I am unable to put the standard functionality of the link "copy mailing address to other adderess"

Can anybody help regarding this?

I'm using standard controller for displaying fields.

Thanks in Advance!

R_Shri
  • February 03, 2014
  • Like
  • 0

Hey there,

 

I have created a VF page with extension that will re-direct the user to a visualforce page with the correct tab open after creating a new record. I tried putting that same page onto the clone button and although it autofilled the correct fields, upon attempting to save I was left with this:

 

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

Error is in expression '{!SaveFactFinder}' in component <apex:commandButton> in page factfinderext

 

 

Class.extSaveButton.saveFactFinder: line 11, column 1

 

 

Am I able to do it like this or do I have to create an entirely different VF page and extension?

 

Thank you,

 

Mikie

I'm being asked to write test classes for my apex code and I guess I just don't understand how to write it.  How do you write a test code for this?

 

Any help is greatly appreciated.  Reading An Introduction to Apex Code Test Methods is like listening to Charlie Brown's teach talk, it makes no sense to me...

 

public with sharing class cancelChange {
public Boolean isDisplayPopUp {get; set;} 
    public cancelChange(ApexPages.StandardController controller) {

    
isDisplayPopUp = true;    
{Change__c chge = (Change__c) controller.getRecord(); chge.StatusChange__c = 'Cancelled'; }   
}}

 

  • September 26, 2013
  • Like
  • 0

Dears,

 

I have a search page with several conditions, I pass the conditions to controller and make my search soql like this:

String soql = 'select Id , Name from Account where';
if (a != null) {
    soql += ' and xxx__c = \'' + a '\''
}
if (b != null) {
    soql += ' and yyy__c = \'' + b '\''
}
......
List<Account> accList = Database.query(soql);

It seems like cannot pass the security scan because this is a soql injection.(Well, I just heard about that, I don't know whether this really cannot pass the scan...)

 

I read the wiki and other documents, they just say you should use static soql to put the parameters, like this:

PreparedStatement query = "select * from users where userid = :user and password = :password";
query.bindInt("user", Request.form("user").intValue());
query.bindString("password", getSaltedHash(Request.form("password")));
Database.executePreparedStatement(query);

But in my situation, I need to make the where clause dynamicly.

Is there some solutions to deal with it?

Waiting for your answers.

Thank you.

How to display selected startDate to endDate in a pageBlockTable?
For example, I selected January 1 as startdate and January 5 as enddate. How can I display each date in different rows?

  • September 03, 2013
  • Like
  • 0

Hi Friends ,

 

I have two custom objects one is Student and the other is hostel .There do have a look up relation (child : hostel , parent:student).

Scenario is : I have a Confirm hostel as checkbox field in student Object.when i create a record in student and check the confirm hostel field a record should be created in hostel.The code works fine.

The other criteria is i have a gender as picklist field in student object.when i select the gender value as MALE and check the confirm hostel field a record should be created in hostel .The code works fine.

But when i edit and do some changes like changing the gender to female  then the record gets saves as MISSMRSTUDent or unchecking the confirm hostel field then the record gets saved as MISSMISSMRSTUDENT.

Can any one help me in this code.

 

CODE :

trigger autoupdatehostel on Student__c (before insert,before update,after insert,after update)
 {
if(trigger.isbefore)
{
if(trigger.isinsert || trigger.isupdate)
{
 // In before insert or before update triggers, the trigger accesses the new records
    // with the Trigger.new list.

for(Student__c st : trigger.new)
{
if(st.Gender__c=='Male')
{st.Name = 'Mr'+st.Name;
}
else if(st.Gender__c=='Female')
{
st.Name ='Miss'+st.Name;
}
}
}
}
// If the trigger is not a before trigger, it must be an after trigger.
else if(trigger.isafter)
{
if(trigger.isinsert || trigger.isupdate)
{
list <Hostel__c> newhost = new list<Hostel__c>();
{
for(Student__c st : trigger.new)
{
 if(st.ConfirmHostel__c==true)
{
//Hostel__c ht = new Hostel__c();
//ht.Name = st.Name+'Hostel';
//ht.RefStud__c=st.id;
newhost.add(new Hostel__c(Name = st.Name+'Hostel',
                          RefStud__c=st.id));
}
insert newhost;
}
//if(newhost.size()>0 && newhost!=null)
//{
//insert newhost;
//}
}
}}
}

I Shall appreciate ur help

  • August 23, 2013
  • Like
  • 0

Hi,

 

I have a VF pafe and its controller. I am getting all records.

 

However, I want to append the functionality:

 

1. On selecting (mark true check box) the records, i want to show only the selected records in the below page block and want to show the number of counts of the selected records:

 

 

Page:

 

<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>


</apex:pageBlock>

</apex:form>
</apex:page>

 

Controller:

 

public class wrapperClassController {

//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}
//This method uses a simple SOQL query to return a List of Contacts

public Boolean Myvalue{get;set;}
public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
// As each contact is processed we create a new cContact object and add it to the contactList
contactList.add(new cContact(c));
}
}
return contactList;
}


public PageReference processSelected() {

//We create a new list of Contacts that we be populated only with Contacts if they are selected
List<Contact> selectedContacts = new List<Contact>();

//We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
for(cContact cCon: getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}

// Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Contact con: selectedContacts) {
system.debug(con);
}
contactList=null; // we need this line if we performed a write operation because getContacts gets a fresh list now
return null;
}


// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}

//This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
public cContact(Contact c) {
con = c;
selected = false;
}
}
}

  • August 23, 2013
  • Like
  • 0

hiii this is my test class....i just want to write a test coverage for this code.....but i got only 50% of code coverage...can anyone plsss...help me out....

 

public class MultipleStdntView1_AC
{
   public pagereference save()
   {
       return null;
    }
   String recordId;
   public MultipleStdntView1_AC()
   {
      recordId = system.currentpagereference().getparameters().get('id');
      c = [select Name,dept_email__c,dept_ID__c from department__c where id =: recordId];
      stdntlist = [Select Name,Email__c,phone__c,percentage__c from Student__c where department__c =: c.id];
    }
  
   Department__c c = new Department__c();
   public department__c getdepartmentDetails()
   {
     return c;
   }
   List<Student__c> stdntlist = new List<Student__c>();
   public List<Student__c> getstudentDetails()
   {
     return stdntlist;
   }
   public PageReference edit() 
    {
        return null;
    }

    public PageReference deleteRecords() 
    {
        return null;
    }
   
}

 

 

the red colored lines are the uncovered....

and also can you pls..tel me about "how to call a list & a loop?

  • August 09, 2013
  • Like
  • 0

hi,

 

I want the code for which when the user clicks the custom button like "Proceed" ,then the user has to transfer the page to New Lead Registering page.. how to do it in VF page...can u please send the code

Hello,

 

 

I have successfuly imeplemented the code below for a custom object, however I can not find any test methods examples over the boards for the same need.

 

Can anybody please help me write a simple test method for the following class?

 

public with sharing class RelatedController 
{
 private ApexPages.StandardController stdCtrl;
  
 public RelatedController(ApexPages.StandardController std)
 {
  stdCtrl=std;
 }
  
 public void AccountPopulated()
 {
  Contact cont=(Contact) stdCtrl.getRecord();
  cont.Account=[select AccountNumber, Site from Account where id=:cont.AccountId];
 }
}

 

Original post at BobBuzzard blog

 

Thanks!!!

 

Ronaldo.

Hi  all, I am a bit new to salesforce and i succesfully wrote this trigger. But i am lack of ideas on bulkifying it. The below trigger is a basic trigger to check if a contact is linked to a program or opportunity or account.

 

trigger CheckLinktoPrograms on Contact (after update,before delete) {

if(trigger.isupdate){
List<ProgramContactRole__c> lstConRole = new List<ProgramContactRole__c>();
List<AccountContactRole> lstConRole3 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole4 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.new){
setContactId.add(c.id);
}
lstConRole=[select id,name,ContactId__c,ProgramId__c,ProgramId__r.name from ProgramContactRole__c where ContactId__c IN:setContactId];
lstConRole3=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole4=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];


for(integer i=0;i<trigger.new.size();i++){

  if(trigger.new[i].Active__c==false ){
 
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
 
 }
 if(trigger.new[i].To_be_deleted__c == true){
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
  }
}
}

if(trigger.isdelete){
List<AccountContactRole> lstConRole1 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole2 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.old){
 setContactId.add(c.id);

 }
lstConRole1=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole2=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];

for(integer i=0;i<trigger.old.size();i++){

  for(AccountContactRole acr:lstConRole1){
    if(acr.ContactId==trigger.old[i].id){
    string accountname='<html><bold>';
    accountname+=acr.Account.name;
    accountname+='</body></html>';
     trigger.old[0].addError('Cannot delete Contact if its linked to an Account: '+accountname+' with a Role ( Contact Role ) ');
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole2){
    if(ocr.ContactId==trigger.old[i].id){
     trigger.old[0].addError('Cannot delete Contact if its linked to an Opportunity: '+ocr.Opportunity.name+' with a Role ( Contact Role ) ');
   }
  }
 
 }
 
 
}


}

 

I have taken some code for a layered chart and adapting to my own. It is on a custom object called X3RE_Snapshot_Data__c. The controller seems to save fine, but the VF page gives me an error Unknown property 'threeREChartController.getData' Usually I can figure that out - but I am at a loss. I figure my controller is messed up somewhere. Below if the code for both.

 

public with sharing class threeREChartController{


    public threeREChartController (){}

    public List<SnapshotData> getData() {
        AggregateResult[] result = [SELECT id,SUM(X3RE__c) daily3RE, AVG(X3RE__c) dailyavg3RE,
                                    CALENDAR_MONTH(CreatedDate) month,
                                    CALENDAR_YEAR(CreatedDate) year
                                    FROM X3RE_Snapshot_Data__c GROUP BY ID,
                                    CALENDAR_YEAR(CreatedDate),CALENDAR_MONTH(CreatedDate)
                                    HAVING 
                                    CALENDAR_YEAR(CreatedDate) = 2013];
                                    

        List<SnapshotData> threeREData = new List<SnapshotData>();
        for (AggregateResult a : result)
        {
            Datetime d=Datetime.newInstance((Integer)a.get('year'),(Integer)a.get('month'), 1);
            SnapshotData snap = new SnapshotData(d.format('MMM'),
                                                      (Double)a.get('dailyavg3RE'),
                                                      (Double)a.get('daily3RE'));     

            threeREData.add(snap);
        }
        return threeREData;
    }

    public class SnapshotData
    {
        public String month { get; set; }
        public Double dailyavg3RE { get; set; }
        public Double daily3RE { get; set; }

        public SnapshotData(String mon, Double davg, Double daily)
        {
            month = mon;
            dailyavg3RE = davg;
            daily3RE = daily;
        }
    }
}

 

 

<apex:page controller="threeREChartController" showHeader="false" sidebar="false">
    <apex:sectionHeader title="3RE"/>
    <apex:chart height="380" width="700" data="{!getData}">
        <apex:legend position="right"/>
        <apex:axis type="Numeric" position="left" fields="dailyavg3RE"
            title="Average"/>
        <apex:axis type="Category" position="bottom" fields="month"
            title="Month of the Year">
            <apex:chartLabel rotate="315"/>
        </apex:axis>
        <apex:barSeries title="3RE" orientation="vertical" axis="left"
            xField="daily" yField="daily3RE">
            <apex:chartTips height="20" width="120"/>
        </apex:barSeries>
        <apex:axis type="Numeric" position="right" fields="daily3RE"
            title="3RE" grid="true"/>
        <apex:lineSeries title="3RE" axis="right" xField="month" yField="daily3RE"
            fill="true" markerType="cross" markerSize="4" markerFill="#FF0000"/>
    </apex:chart>
</apex:page>

 One other quick question - can you add filters to the vf charts?

Hi All, 
My requirement is show a popup message on the opportunity page(Standard page is overidden with custom vf page using apex detail) when opportunity is closed. Say two persone is wokring on same opportunity then one person closd that opportunity from his side, so other person should see the message that opportunity is being closed without having to refrsh the page.

For this requirement i thought of implmenting Striming API, so I have craeted a pushtopic and craeted to dummy vf page just to check whether the stage chnage is reflected or not, unfortunatley it is not refreshing. Could you please help me to solve my issue.

Here is pushtopic i created.
PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'InvoiceStatementUpdates';
pushTopic.Query = 'SELECT Id,Name,StageName FROM Opportunity';
pushTopic.ApiVersion = 39.0;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
pushTopic.NotifyForOperations = 'Update';
insert pushTopic;

Here is vf page
<apex:page id="PG" controller="StreamingAPIController">
<apex:form id="FRM">

    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery_StrimingApi}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>

    <apex:actionFunction name="GetRefreshedOpportunities" reRender="PB,PBT"/>

    <script type="text/javascript">
        (function($)
        {
            $(document).ready(function() {
                
                // Connect to the CometD endpoint
                $.cometd.init({
                    url: window.location.protocol+'//'+window.location.hostname+'/cometd/36.0/',
                    requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
                });
                
                // Subscribe to a topic. JSON-encoded update will be returned in the callback
                // In this example we are using this only to track the generated event
                $.cometd.subscribe('/topic/InvoiceStatementUpdates', function(message)
                {
                    //You can use message as it will return you many attributes
                    //I am just using to track that event is generated
                    GetRefreshedOpportunities();
                });

            });
        })(jQuery)
    </script>

    <apex:pageBlock id="PB">
        <apex:variable var="count" value="{!0}" />
        <apex:pageBlockTable id="PBT" value="{!getRefreshedOpportunity}" var="opp">
            
            <apex:column headerValue="S.No.">
                <apex:variable var="count" value="{!count+1}" />
                {!count}
            </apex:column>
            <apex:column value="{!opp.id}" headerValue="id"/>
            <apex:column value="{!opp.Name}" headerValue="Name"/>
            <apex:column value="{!opp.StageName }" headerValue="StageName "/>
            
        </apex:pageBlockTable>
    </apex:pageBlock>

</apex:form>
</apex:page>

here is controller 
public class StreamingAPIController
{
    //Everytime page is reRendered it will get refreshed values of Opportunity 
    public List<Opportunity> getRefreshedOpportunity
    {
        get
        {
            return [select Id, Name,StageName from Opportunity  LIMIT 10 ] ;
        }
        set;
    }
    
    public StreamingAPIController()
    {
    }
}
But in workbench i can see the notification and stage name, I am confused why it is not reflectying in Vf pages. 
Message received from: /topic/InvoiceStatementUpdates
{
  "channel": "/topic/InvoiceStatementUpdates", 
  "clientId": "1ix3i3kz92l8b8z13m10pafuf5tz", 
  "data": {
    "event": {
      "type": "updated", 
      "createdDate": "2017-01-26T04:28:36.000+0000"
    }, 
    "sobject": {
      "StageName": "Closed Lost", 
      "Id": "006G000000P3j6CIAR", 
      "Name": "MVC Componentes Plasticos Ltda.-LTD&CFR Domestic-Sep-15-13"
    }
  }
}

Please help me 
Hi Guys
I am able to encrypt some value ,But I dont know while I am doinf decrypt some error is showing
System.StringException: Unrecognized base64 character: %
Error is in expression '{!test}' in component <apex:commandButton> in page encryptpageformac

I am sharing my page and controller , Help me guys as soon as possible

My page
<apex:page standardController="EnCrypt_Decrypt__c" extensions="EncryptExtensionForMAC">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!encrypt.Name}"/>
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Update" action="{!test}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My controller
public class EncryptExtensionForMAC {
    public EnCrypt_Decrypt__c encrypt{get;set;}
    public String secretkey = 'INVOICEITAPIACERTISCLOUDSEP2010';
    Blob cryptoKey = Blob.valueOf(secretkey );
    String algorithmName = 'HMACSHA256';
    public Id recordId{get;set;}
    public EncryptExtensionForMAC(ApexPages.StandardController controller) {
      
        //cryptoKey = Crypto.generateAesKey(256);
        recordId = Apexpages.CurrentPage().getParameters().get('id');
        if(recordId !=null){
            encrypt = [SELECT id,Name From EnCrypt_Decrypt__c
                    WHERE id=:recordId];
        }
        else{
            encrypt = new EnCrypt_Decrypt__c();
        }
    }
  
    public PageReference Save(){
       
       
         Blob input = Blob.valueOf(encrypt.Name);
         Blob signing =Crypto.generateMac(algorithmName, input, cryptoKey);
         //String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(signing), 'UTF-16');
        String macUrl = EncodingUtil.base64Encode(signing);
         encrypt.name = macUrl;
       
         insert encrypt;
         return null;
    }
  
     public PageReference test(){
         Blob input = EncodingUtil.base64Decode(encrypt.Name);
      
         Blob signing =Crypto.generateMac(algorithmName, input, cryptoKey);
         String macUrl = signing.toString();
         encrypt.name = macUrl ;
       
         update encrypt;
         return null;
    }

}
Error is showing when I am clicking on the Update button.

Hi 

 

I am calling a salesforce standard page in a iframe, That means I am calling a standard salesforce page in a VF page by using iframe. I am able to hide the header and side bar of standard page, But when I am clicking on New standard button .It is not working . Do you know how will do it?

 

<apex:page>
<iframe height="500px" id="theIframe" name="theIframe" src="https://ap1.salesforce.com/001/o?isdtp=vw" width="100%" scrolling="false" frameborder = "true"/>
</apex:page>

 

Please help me

Hi 

I have configured all the things according to the documentations 

http://www.salesforce.com/us/developer/docs/daas/index_Left.htm#StartTopic=Content%2Fdaas_destructive_changes.htm%7CSkinName=webhelp

 

when I am trying to run migration tool by entering ant retrieveUnpackaged in command mode .I am getting this error 

"Buildfile: build.xml does not exists ! Build failed"

 

I have build.xml in my directory.

 

Any help and sugessions?

Hi
can any one tell me regex form of 999-999-9999 this?

I have used phoneRegex = '\\D*?(\\d\\D*?){10} but Now I want to restrict the special charatcter entry. It is acepting all the  special characters

I am giving this input.It is taking, I want to restrict that.

how will I do, please give me some suggession as soon as possible.

 

 

Thanks

 

 

HI

I have one dependant picklist and one controlling picklist of position object, I want to display one picklist in one output panel and another in other panel by clicking next button, so please anyone can suggest me how will I do that?

This is my page

<apex:page controller="testtt">
<apex:form>
    
  <apex:outputPanel rendered="{!visible == false}">
      <!--<apex:inputField value="{!pos.Functional_Area__c}" id="test" onchange="confirmDisbaled('{!$component.test}');"/>-->
      <apex:inputField value="{!pos.Functional_Area__c}" id="test" />
       
      <apex:commandButton value="Next" action="{!next}"/>
  </apex:outputPanel>
 
  <apex:outputPanel rendered="{!visible == true}">
      
      <apex:inputField value="{!pos.Job_Level__c}" />   
  </apex:outputPanel>
 
</apex:form>
</apex:page>

I want to display corresponding joblevel which are under Function Area of postion picklist.

My controller is

public class testtt{

    public Position__c pos{get; set; }
    public Boolean visible{get;set;}
    public testtt(){
        pos = new Position__c();
        visible = false;
    }
    public void next(){
      
        visible = true;
    }
}

 

Please suggest me some idea as soon as possible..

 

Thanks

Hi

   I want to create portal user . when I create new user then Role profile and Licence auto populated . 

   I want these value should not be auot populated.. I want to select licence  and profile as

   

Authenticated WebsiteHigh Volume Customer PortalCustomer Portal Manager StandardCustomer Portal Manager Custom

 

But Unfortunately these value will not be avialable in profile and Licence picklist ....

Auto populated value...

ROLE:CEO

PROFILE : Force.com free user

Licence:Force.com free user ..

 

I want toavoid this scenario ... please helpme as soon as possible...

 

 

Thanks

asish

Hi 

Can you tell me how can I remove record Type that I created ......?

When I deactivate that recordType an error is fired...

This record type ReleasedType cannot be deactivated because the following profiles use this record type as default.

profile 's are...

System Administrator

StandardPlatform User

Custom: MarketingProfile

Custom: Sales Profile

Custom: Support Profile

Force.com - Free User

Gold Partner User

Standard User

Read Only

Solution Manager

Marketing User

Contract Manager

Potential

Silver Partner User

 

Please help me as soon as possible..

 

 

 

Thanks

asish

Hi 

I have a custom Object which has Status__c field(picklist type) .Status has different values such as 'RELEASED' , 'EDITED'.   'IN TIMER MODE' , 'STARTED' , 'CLONED' . I have two recordType 'ReleasedType'  and  'UnReleasedType' and also two layout 

Released layout and UnReleased layout . Relesed layout has ReleasedType and Uneleased layout has UnReleasedTyoe field .

Now my requirement is... When I click on my custom object to view records ... It should ask which record Type to choose.. If I choose Released Type then I can only see All released Record in Releasedlayout .same for Unreleased Type .

Please help me as soon as possible... Its urgent ... 

 

Thanks

asish

Hi

  I have an apex class which is all about an Opportunity and Quote and Product informations.

 I mean ...Contact--->Opportunity---->Quote-->QuoteLineitem-- Product

 I have written a test method ... I have entered an record of Opportunity and it is already inserted . I have checked bu debur log... But still I am facing an exception...

  System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, StageName, CloseDate]: [Name, StageName, CloseDate]

 

This is my class......

 

   

public class Pcontactdetailcontroller {

//All Getter and Setter Properties.....

public Contact contact {get;set;}
public List< OpportunityContactRole> optcList{get;set;}

public String visible {get;set;}
public String Enable{get;set;}
public OpportunityContactRole optc {get;set;}
public Opportunity opt{get;set;}
public Quote quote{get;set;}
public String opptId{get;set;}
public String table{get;set;}
public String asish{get;set;}
public String block{get;set;}
public Id optId{get;set;}
public Id Id{get;set;}
public Id quoteId{get;set;}
public Id lineitemId{get;set;}
public List<Quote> quotelist{get;set;}
public List<Opportunity> optlist{get;set;}
public PricebookEntry pbentry{get;set;}
public Pricebook2 pb{get;set;}
public Product2 product{get;set;}
public QuoteLineItem qutlineitem{get;set;}
public QuoteLineItem qutlineitem1{get;set;}
public Quote quote1{get;set;}
public Opportunity opt1{get;set;}


//constructor

public Pcontactdetailcontroller() {

Id = ApexPages.currentPage().getParameters().get('Id');
contact=[select Id,FirstName,LastName, name,Account.Name,MailingStreet,MailingState,MailingCity,MobilePhone,Email from Contact where Id=:Id];

optc=new OpportunityContactRole();
opt=new Opportunity();
opt1=new Opportunity();
quote=new Quote();
pb= new Pricebook2();
pbentry= new PricebookEntry(UseStandardPrice=true,UnitPrice=0.00);
product=new Product2();
qutlineitem=new QuoteLineItem();
qutlineitem1=new QuoteLineItem();
quote1 = new Quote();
}



//All getter method

public OpportunityContactRole getOpportunityContactRole() {

return optc;
}

public Opportunity getOpportunity() {

return opt;
}


public Opportunity getOpportunity1() {

return opt1;
}

public Quote getQuote() {

return quote;
}

public Contact getContact() {

return contact;
}

public Product2 getProduct2() {

return product;
}
public Pricebook2 getPricebook2() {

return pb;
}
public PricebookEntry getPricebookEntry() {

return pbentry;
}
public QuoteLineItem getQuoteLineItem() {

return qutlineitem;
}

public QuoteLineItem getQuoteLineItem1() {

return qutlineitem1;
}
public Quote getQuote1() {

return quote1;
}

//Editin Contact Details......

public PageReference tochange() {

Id Id = ApexPages.currentPage().getParameters().get('Id');
Enable='edit2';
System.debug('##############visible###############'+visible);
return null;

}

//Saving contact details
public PageReference toupdatecontact() {

Id Id = ApexPages.currentPage().getParameters().get('Id');
PageReference samepage=new PageReference('/apex/pcontactdetail?id='+id);
samepage.setRedirect(true);
update contact;
Enable=null;
return null;
}


//opportunity save

public PageReference tosaveOpportunity() {

opt.AccountId = contact.AccountId;
insert opt;
optc.OpportunityId=opt.id;
optc.ContactId=contact.id;
insert optc;
visible=null;
PageReference samepage= new PageReference('/apex/pcontactdetail?id='+id);
samepage.setRedirect(true);
return samepage;
}

 

Error is on insert opt  line....

 

My test method is.....

 

  

private static testmethod void t1() {
Id Id;
test.startTest();
Account act = new Account (Name = 'xyt');
insert act;
Contact con = new Contact( LastName = 'cghj' , AccountId = act.id);
insert con;
// Date myDate = date.newinstance(2018, 2, 17);

Opportunity opttest = new Opportunity(AccountId = act.Id,Name = 'test' , StageName = 'Closed Won', CloseDate = System.today() );
insert opttest;
ApexPages.currentPage().getParameters().put('Id',con.id);

System.debug('#########################OPPORTUNITY################'+opttest.Name);
System.debug('#########################OPPORTUNITY################'+opttest.AccountId);
System.debug('#########################OPPORTUNITY################'+opttest.CloseDate );
System.debug('#########################OPPORTUNITY################'+opttest.StageName );
OpportunityContactRole optctest = new OpportunityContactRole(ContactId = con.id , OpportunityId = opttest.id );
insert optctest ;

............

}

 

So wnat will I do ... Anyone have any suggession please help me... Its urgent...

 

 

Thanks

asish

 

 

 

Hi 

  I want to draw a bar an pie chart in visualforce page . I know It  can be by using GooglechartApi , But I want to draw by using 

  

  <apex:chart> .  I have treid alot . 

   here is my code . 

 

  

<apex:page controller="OppsController">
<apex:chart data="{!BarWedgeData}" width="600" height="400">
<apex:axis type="Category" position="left" fields="name" title="Opportunities"/>
<apex:axis type="Numeric" position="bottom" fields="amount" title="Amount"/>
<apex:barSeries orientation="horizontal" axis="bottom" xField="name" yField="amount"/>
<!--<apex:pieSeries dataField="amount" labelField="name"/>-->

</apex:chart>
<apex:dataTable value="{!BarWedgeData}" var="opp">
<apex:column headerValue="Opportunity" value="{!opp.name}"/>
<!--<apex:column headerValue="Amount" value="{!opp.amount}"/>-->
</apex:dataTable>
</apex:page>

 

 

My class code is 

 

 

public class OppsController {

// Get a set of Opportunities
public List<Opportunity> opptList{get;set;}

/* public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}*/

List<BarWedgeData > data {get;set;}

public OppsController() {
opptList = [SELECT name, type, amount, closedate FROM Opportunity limit 10];
data = new List<BarWedgeData>();


}
public List<BarWedgeData > getBarWedgeData () {
for(Opportunity opt : opptList)
{
//data = new List<BarWedgeData>();
data.add(new BarWedgeData (opt.name));
}
//data.add(new BarWedgeData (opt.closedate));
return data;

}


public class BarWedgeData {

public String name { get; set; }
public Double data { get; set; }

public BarWedgeData (String name) {
this.name = name;
this.data = data;
}
}

}

 

here I have written code to dislaay all Opportunity name in a list and a graph.

  List is displayed but graph is not displayed. please help me as soon as possible

 

Thanks

asish

 

Hi
I was trying to implement VisualForce charting , I have written  a code for piechart .But unfortunately I am getting an error.
Error: Unknown component apex:chart in piechart..... I have searched out , then got information , I have to enable VisualForce
charting , For that I need to send a mail , So I did .I need your support and help to enable VisualForce charting as soon as possible. maybe Pilot Program need to be enabled.

 

So please tell me how do I contact salesforce support .. Anyone facing same difficulty please help me...Its urgent

 

Thanks
asish

Hi All

    I have designed a page which show all record of account in a pageBlock table. I want to add inline support.when user double clicked on any coloum value to which he wants to edit....then a window appears showing that field for edit and two buttom  "save" and cancel  present in that window and parent window becomes shaded.new window is like alert in javascript.

I was thinking that I will design an outputpanel and in that panel field for edit and two button present and also will set rendred property on that panel.BUt problem is that how can set that rendred value on double click....I mean can I call an apex method on <apex:inlineEditsupport....>...so If any one any idea please tell me.....

If you want to more about the problem please click on that url ....I just want to make that way

 

https://c.ap1.visual.force.com/apex/popup?retURL=%2F00Q90000005tQ7a&scontrolCaching=1&id=00Q90000005tQ7a&id=00Q90000005tQ7a&sfdc.override=1

Then double click on phone field....show what am trying to do

Help me as soon as possible....

 

Thanks

asish

Hi..

 

  can anyone say about field of Event Object...?

 I have seen there are Email and phone field present in Event Object but when I am writing Event.Email then an error is fired that No such field is present in Event object.

Here is the Link for displaying Email and phone field present

 

https://ap1.salesforce.com/p/setup/layout/LayoutFieldList?type=Event&setupid=EventFields&retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DActivity

 

 

But when I am trying to display the value an error occurs

event = [select id,Email,Phone,Subject from Event where who__id=:contact.Id] ;

apex:outputField value="{!event.Phone}"/>

 

 

 

please help me

asish

Hi all

 

I want to design an application in which an employees table present which keeps all information about an employee.A Lead(project manager ) is also an employee.Lead 's information also is presnt in employee.A general employee has more then one Lead.that means he is under more than one Lead.so how can I design database.

1-how can I get total number of Lead

2-how can I get Lead of a particular employee..

Please suggest me what will I do ?.

I tried by using self join but I am unable to get infomation if an employee has more than one Lead.

So please help me as soon as possible ......

 

Thanks

asish

Hi All

 

     would you loke to tell how to delete custom portal user ....  ?

 

 

Thanks

asish

 

 

 

 

Hi

 I need  RecruitingApp-5_0.zip file 

 

Please help me as soon as possible ...........

 

 

 

Thanks with Regards

asish

Hi

 can anyone tell me how a java script method and controller method executed at same button click...?

 

 

 <apex:commandButton value="Turn Quote Into Order" action="{!forOrder}" style="float:left" rerender="Outputpanelid"  oncomplete="window.top.close()"/>

 

controller method is forOrder

 public PageReference forOrder() {
      
       Id  Id = ApexPages.currentPage().getParameters().get('Id');
       quoteId = ApexPages.currentPage().getParameters().get('quoteId');
       PageReference newpage = new PageReference('/apex/pcontactdetail?Id='+Id+'&quoteId='+quoteId);
       newpage.setRedirect(true);
         return Page.newpage;
             
                  } 

 

when I execute this code window is not be closed but anather page is opened.that means may be java script method is not executed.

If any one have suggestion help me with example......

Hi Everyone

  I have designed a page which shows all Opportunity in pageblock table .When I click on Opportunity Name a popup window of anather page is appeared  which show all the Quote in a particular Opportunity .I have also displayed all product in particular Quote in that popupwindow.Now I want to  pass QuoteId from current window to existing window.I also want to close this window.please anyone suggest me because I am new In salesforce.

 

Here is My code

 

<apex:page controller="pcontactdetailcontroller">
<script type= "text/javaScript">
var newWin=null;
 function openLookupPopup(Id)
 {
 //alert('Lokup'+rId);
  var url="/apex/pcontactdetailpopup?Id=" + Id ;
  newWin=window.open(url, 'Popup','height=700,width=800,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
  if (window.focus)
  {
   newWin.focus();
  }
    
     return false;
    }

</script>

<apex:pageBlockSection title="Opportunity Details">
                 <apex:outputPanel  rendered="{!Enable!='asish'}">
                      <p><B> Oppertunity Details</B> <apex:commandButton value="Add Opportunity" action="{!forOpportunity}" style="color:blue,font-weight:16"/></P>
                      <apex:pageBlockTable value="{!OpportunityContactRoles}" var="conopportunity"  cellpadding="2" border="1"  rowClasses="odd,even" styleClass="tableClass">
           
                           <apex:column headerValue="Order No">{!conopportunity.Opportunity.OrderNumber__c}</apex:column>
                           <apex:column headerValue="Close Date">{!conopportunity.Opportunity.CloseDate}</apex:column>
                           <apex:column headerValue="Oppertunity Name">
                              <apex:commandLink value="{!conopportunity.Opportunity.Name}" action="{!forQuote}" id="opptname" title="for Quote Details" style="color:blue" onclick="openLookupPopup('{!conopportunity.Opportunity.Id}' ); return false">
                                   <apex:param name="optId" value="{!conopportunity.Opportunity.Id}" />
                              </apex:commandLink>
                            </apex:column>
                            <apex:column headerValue="Action">
                                    
                               <apex:commandLink value="AddQuote" title="to add Quote" action="{!toAddQuote}" style="color:blue" >
                                   <apex:param name="optId" value="{!conopportunity.Opportunity.Id}" />
                               </apex:commandLink>
                            </apex:column>
                            
                     </apex:pageBlockTable>

 

This Is my first page code.I have sent OppertunityId to pcontactdetailpopup page.

 

Now my popup window page code is

<apex:page controller="pcontactdetailpopupcontroller">

<apex:form>
  <apex:pageBlock title="All Quotes">

  <apex:pageBlockSection title="Quote Details">
  <apex:outputPanel style="float:middle">
                    <p><B>OPPORTUNITY NAME</B>:&nbsp;{!Opt.Name}<br/>
               
                     <B> All Quotes </B></P>
                          <apex:pageBlockTable value="{!opt.Quotes}" var="Qut" cellpadding="2" border="1"  rowClasses="odd,even" >
                               <apex:column headerValue="Quote Number">{!Qut.QuoteNumber}</apex:column>
                               <apex:column headerValue="Status">{!Qut.Status}</apex:column>
                               <apex:column headerValue="Quote Date">{!Qut.ExpirationDate}</apex:column>
                               <apex:column headerValue="Quote Name">
                                    <apex:commandLink value="{!Qut.Name}" action="{!forProduct}" style="color:blue" title="for Product Details">
                                        <apex:param name="quoteId" value="{!Qut.Id}" />
                          
                                    </apex:commandLink>
                               </apex:column>
                               <apex:column headerValue="Action">
                                     <apex:commandLink value="AddProduct" title="to add Quote" action="{!toAddProduct2}" style="color:blue">
                                         <apex:param name="quoteId" value="{!Qut.Id}" />
                                      </apex:commandLink>
                           
                                </apex:column>
                        
                        </apex:pageBlockTable>

 

<apex:commandButton value="Turn Quote Into Order" action="{!forOrder}" style="float:left"  onclick="window.top.close();"/>

Here simply window is closed.But I want to pass QuoteId to existin window.For this propose I have written methode in controller class.

public Id quoteId{get;set;}

public Pagereference forOrder() {

 

quoteId = ApexPages.currentPage().getParameter.get('quoteId');

PageReference samePage = new Paferefernce('/apex/pcontactdetailpopup?Id='+quoteId);

return samePage;

}

I think window is closed by java script.window.top.close();

.After that the controller method may not be executed.But I knew that controller method is executed after java script method.

please suggest me as soon as possible.

 

 

 

 

 

Hi Everyone

I want to add more product in a perticular Quote.I know the relationship between Quote,QuoteLineItem ,Pricebook2,Product2 and PricebookEntry.my first product is saved but when I am  trying to add more product under a perticular Quote an error is fired.

"Id is not specified in an update call.."  .I have written update statement to update Quote because there is a required field Pricebook2Id in Quote.when I  am creating a new product at that time assisgning a unit price through PricebookEntry.Because Product2 and Pricebook2 are related in a many to many relationship and the junction object is PricebookEntry.

My problem is that how can we update PricebookId field In Quote each time when a Product is created.

That means there is one record in Quote but I have to created more product inside perticular Quote.

 

I am beginner in salesforce.May be I canot express my problem.So I request please help me in a simpler way....

Here is my code.

 

<apex:page controller= pcontactdetailcontroller>

................

...............

 

       <!----QUOTE table-->
  <apex:pageBlockSection title="Quote Details of a Perctcular Opportunity" rendered="{!table=='Show'}">
           
                <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B>
            <!--<apex:outputField label="OPPORTUNITY" value="{!OpportunityContactRoles.Opportunity.Name}"/>-->
              <apex:outputPanel style="float:middle">
                  <p><B> All Quotes </B></P>
                 <apex:dataTable value="{!Opportunity1.Quotes}" var="Qut" cellpadding="2" border="1"  rowClasses="odd,even" >
           
                    <apex:column headerValue="Quote Name">
                    <apex:commandLink value="{!Qut.Name}"  title="to see product" style="font-size:15;color:blue;" action="{!forProduct}">
                     <apex:param name="quoteId" value="{!Qut.Id}"/>
                     </apex:commandLink>
                    </apex:column>
                     <apex:column headerValue="Status">{!Qut.Status}</apex:column>
               
                   </apex:dataTable>
                  </apex:outputPanel>
                  <apex:commandButton value="Add Quote" action="{!toaddQoute}"/>
             </apex:pageBlockSection>

 

 <!--product table------>
                 <apex:pageBlockSection title="Product Details" rendered="{!asish=='Show'}">
            
                  <B>OPPORTUNITY NAME:&nbsp;{!Opportunity1.Name}</B><br/><br/>
                  <B>QUOTE NAME:&nbsp;{!Quote1.Name}</B>
               <apex:outputPanel style="float:middle">
                  <p><B> Product Details </B></P>
                  <apex:datatable value="{!quote1.QuoteLineItems}" var="pdct" cellpadding="2" border="1"  rowClasses="odd,even">
                  <apex:column headerValue="Product Name">{!pdct.PricebookEntry.Product2.Name}</apex:column>
                  <apex:column headerValue="Unit Price">{!pdct.UnitPrice}</apex:column>
                  <apex:column headerValue="Quantity">{!pdct.Quantity}</apex:column>
                  <apex:column headerValue="Sub Total">"{!pdct.Subtotal}</apex:column>
                  <apex:column headerValue="Discount">"{!pdct.Discount}</apex:column>
                  <apex:column headerValue="TotalPrice">{!pdct.TotalPrice}</apex:column>
                  
                  </apex:datatable>
                  
               </apex:outputPanel>
               <apex:commandButton value="Add Product" action="{!toaddProduct}"/>
              
       </apex:pageBlockSection>

.......................

    

         <!--PRODUCT SECTION FOR ENTRY-->
            
            <apex:pageBlockSection title="Product Details" rendered="{!visible=='Step3'}">
            <apex:inputField value="{!Product.Name}"/>
           <!--<apex:inputField value="{!PricebookEntry.UnitPrice}"/>-->
            <apex:inputField value="{!QuoteLineItem.UnitPrice}"/>
            <apex:inputField value="{!QuoteLineItem.Quantity}"/>
             <apex:inputField value="{!QuoteLineItem.Discount}"/>
            <apex:inputCheckbox value="{!PricebookEntry.IsActive}"/>
           
            <apex:commandButton value="save" action="{!tosaveProduct}" style="float:left"/>
            
            </apex:pageBlockSection>

   </apex:page>

here is my controller code.....

 

public class pcontactdetailcontroller {

..................

.................

 public Quote quote{get;set;}

 public PricebookEntry pbentry{get;set;}
     public Pricebook2 pb{get;set;}
     public Product2 product{get;set;}
     public QuoteLineItem qutlineitem{get;set;}

 public Id quoteId{get;set;}

 

 public pcontactdetailcontroller() {

 pb= new Pricebook2();
      pbentry= new PricebookEntry(UseStandardPrice=true,UnitPrice=0.00);
      product=new Product2();
      qutlineitem=new QuoteLineItem();

}

 

 public Quote getQuote() {
       return quote;
       }

public Product2 getProduct2() {
    
        return product;
        }
     public Pricebook2 getPricebook2() {
    
        return pb;
        }
     public PricebookEntry getPricebookEntry() {
    
        return pbentry;
        }
     public QuoteLineItem getQuoteLineItem() {
    
       return qutlineitem;
       }

 

 
    //saving Quote and opening product entry section    
         
    public PageReference tosaveQuote() {
 
       quote.BillingName=contact.Account.Name;
       quote.ShippingName=contact.Account.Name;
       quote.ContactId =contact.Id;
       quote.Phone=contact.MobilePhone;
       quote.Email= contact.Email;
 
      // System.debug('########## quoteOpportunityId######'+ quote.OpportunityId);
       insert quote;
    
       visible='Step3';
   
    // insert quote1;
       return null;
       }
       
    //saving Product   
    
    
   public PageReference tosaveProduct() {
 
       insert product;
 
       pb.Name='Standard';
 
       insert pb;
       pbentry.Product2Id=product.Id;
       pbentry.Pricebook2Id=pb.Id;
    // pbentry.UnitPrice=0.00;  
    // pbentry.UseStandardPrice=true;
   
       insert pbentry;
       quote.Pricebook2Id=pb.Id;
       update quote;
       qutlineitem.PricebookEntryId = pbentry.Id;
       qutlineitem.quoteId=quote.Id;
       insert qutlineitem;
       visible=null;
       Id Id = ApexPages.currentPage().getParameters().get('Id');
       PageReference samepage= new PageReference('/apex/pcontactdetail?id='+id);
       samepage.setRedirect(true);
       return  samepage;
   }

 

 public PageReference forProduct() {
    
       quoteId = ApexPages.currentPage().getParameters().get('quoteId');
      quote1= [select Id,Name,(select Id,PricebookEntry.Product2.Name,UnitPrice,Quantity,Subtotal,Discount,TotalPrice From QuoteLineItems) from Quote where Id=:quoteId];
    
     asish = 'Show';
      return null;
   }

 public PageReference toaddProduct() {
       visible = 'Step3';
       return null;
       }
  }

I have sent necessary code at which I am facing problem.I have faced problem in the line

Update Quote;

kindly reply me as soon as possible...

 

Hi Guys
I am able to encrypt some value ,But I dont know while I am doinf decrypt some error is showing
System.StringException: Unrecognized base64 character: %
Error is in expression '{!test}' in component <apex:commandButton> in page encryptpageformac

I am sharing my page and controller , Help me guys as soon as possible

My page
<apex:page standardController="EnCrypt_Decrypt__c" extensions="EncryptExtensionForMAC">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!encrypt.Name}"/>
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Update" action="{!test}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My controller
public class EncryptExtensionForMAC {
    public EnCrypt_Decrypt__c encrypt{get;set;}
    public String secretkey = 'INVOICEITAPIACERTISCLOUDSEP2010';
    Blob cryptoKey = Blob.valueOf(secretkey );
    String algorithmName = 'HMACSHA256';
    public Id recordId{get;set;}
    public EncryptExtensionForMAC(ApexPages.StandardController controller) {
      
        //cryptoKey = Crypto.generateAesKey(256);
        recordId = Apexpages.CurrentPage().getParameters().get('id');
        if(recordId !=null){
            encrypt = [SELECT id,Name From EnCrypt_Decrypt__c
                    WHERE id=:recordId];
        }
        else{
            encrypt = new EnCrypt_Decrypt__c();
        }
    }
  
    public PageReference Save(){
       
       
         Blob input = Blob.valueOf(encrypt.Name);
         Blob signing =Crypto.generateMac(algorithmName, input, cryptoKey);
         //String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(signing), 'UTF-16');
        String macUrl = EncodingUtil.base64Encode(signing);
         encrypt.name = macUrl;
       
         insert encrypt;
         return null;
    }
  
     public PageReference test(){
         Blob input = EncodingUtil.base64Decode(encrypt.Name);
      
         Blob signing =Crypto.generateMac(algorithmName, input, cryptoKey);
         String macUrl = signing.toString();
         encrypt.name = macUrl ;
       
         update encrypt;
         return null;
    }

}
Error is showing when I am clicking on the Update button.
While developing in Apex, I need to retrieve sandbox name in my code.  How do I do this in Apex?  Thanks in advance.
How to display list of contacts, when I select one contact, it shoud display related account and Opportunity?

please help me......
<apex:page standardController="Request__c" extensions="LocationRequestController" sidebar="false">
<apex:form id="theform">
    <apex:pagemessages id="errorMessage"/>
    <apex:pageBlock >
    <apex:pageBlockButtons location="top">
        <apex:commandButton status="statusId" value="Save" action="{!Save}" />
        <apex:commandButton status="statusId" value="Save & Create Order" action="{!SaveAndCreateOrder}" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection id="Atts">
      <apex:pageBlockSectionItem >
            <apex:outputLabel for="attribute-search-status" value="User"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedUser}" required="true" size="1" style="width:180px">
                <apex:selectOptions value="{!Users}"/>
              </apex:selectList>  
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
          
       <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
      
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>        
              </apex:outputPanel>   
            </apex:pageBlockSectionItem>
      
            <!--<apex:actionFunction action="{!createServiceAgreement}" name="pServiceAgreement" reRender="pServAgreement" />-->
           <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/>
         
            </apex:pageBlockSection>
         </apex:pageblock> 
       
   </apex:form>    
</apex:page>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields:
Location__c and Categories
How to use <apex:actionfunction>.Pls help

           <apex:inputField value="{!ReqUser.Location__c}" required="true"/>
     
             <apex:pageBlockSectionItem >
              <apex:outputLabel for="attribute-search-status" value="Categories"/>
            <apex:outputPanel styleClass="requiredInput" layout="block" >
             <apex:outputPanel styleClass="requiredBlock" layout="block"/>
              <apex:selectList id="attribute-search-status" value="{!selectedCategory}" size="1" required="true" style="width:180px">
                <apex:selectOptions value="{!Categories}"/>
              </apex:selectList>       
              </apex:outputPanel>  
            </apex:pageBlockSectionItem>

I need to populate : <apex:inputField value="{!ReqUser.ServiceAgreement__c}" required="true"/> based on below fields.
How to use <apex:actionfunction>.Pls help
Hi folks, 
       Can anyone tell me how to display the account details using Visualforce Remoting

Thanks in advance
In contact object i have field called MyExpenses(hidden field). This field is populated from CompanyExpenses/no.of.contacts

There two contacts now, So for each contact myExpeness is $100...companyExpensesis $200(constant)

Now if i create another new  contact then Myexpenses filed should be 200/3..

So i need to write trigger to update this hidden field when i create any new contact..

Please help to write this trigger

Thanks
after raising a case to salesforce it  has enabled customer portal for my organization.but it not visible.inorder to make it visible we have to set users for customer portal.can u plz help me in this?because if it is visible then only we can go ahead.
  • September 17, 2014
  • Like
  • 0
Hi,

I am trying to achieve one functionality:

1. Creating a custom button on "CASE" object say "Submit To Web Service"
2. Creating a checkbok field to select one or more case for a certain account.
3. Based on the selection (point#2) it should send out the case related information to some third part web service using Apex call out.

Is this possible to build this logic in salesforce?
How do i enable the edit mode on the base of checkbox is checked or not....i am new in salesforce. so anyone please help me to code.
i want a list with Ist column of checkbox and then rest are contact fields like name etc... and then if i checked the checkbox i want enable the edit mode using the action function.
please sort it out...
I am trying to build a button in the list view to:
Change case ownership to the current user
Change the case status to work in progress

I have the following code in the detail page that works fine:

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var caseObj = new sforce.SObject("Case");

caseObj.Id = '{!Case.Id}';

caseObj.OwnerId = '{!$User.Id}';

caseObj.Status = "Work In Progress";

var result = sforce.connection.update([caseObj]);

window.location.href=window.location.href;

but when I put the button in the list view and click on the button, nothing happens.
it is configured to execute java script as behavior and contentsouce is set to on clickjavascript

Could you guys please provide me some light?
Hi.

I have a custom object (TargetX_SRMb__Application__c) It has a relationship to Contact defined in WSDL by:

  <complexType name="TargetX_SRMb__Application__c">
                <complexContent>
                    <extension base="ens:sObject">

...
                       <element name="TargetX_SRMb__Contact__c" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="TargetX_SRMb__Contact__r" nillable="true" minOccurs="0" type="ens:Contact"/>

However, when I run SOQL test as:

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contact__r) FROM Contact c]

I get error:

Error: Compile Error: Didn't understand relationship 'TargetX_SRMb__Contact__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name

I also tries adding a "s" as follows: Same error.

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contacts__r) FROM Contact c]

 Is this not the correct syntax to query child records from a custom object?

Thanks in advance,

Jon
error- System.NullPointerException: Attempt to de-reference a null object
Code-To test trigger After insert.

//after insert statement. Note testcase is a listof Case. 
for(case c:testcase)
      {  AssignmentRule AR = new AssignmentRule();
        AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
        System.debug('Assignment rule id' + c.getOption().assignmentRuleHeader.assignmentRuleId);//c
        System.assertEquals(c.getOption().assignmentRuleHeader.assignmentRuleId,AR.id);//c
     
      }
Ho to share the all opportunty records from Salesforce orgA to salesforce org B using Batch class..
If you have any code can you please share me..

<apex:page standardController="WO_Comments__c">
    <apex:pageBlock title="Description" >
        <apex:pageblockTable value="{!WO_Comments__c}" var="WO_Comments__c">
             <apex:outputText value="{!WO_Comments__c.Comment__c}" />
        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>

I am having somewhat of the same issue.  I do not get an error however, the custom object will not appear after I enter the code in.

If you see the attached picture where I do apex:pageblock description it shows but, when for the custom object whether I do ouput text or pageblock table I cannot get the custom object to appear
User-added image
Below is what it should look like. This is the custom object I am trying to referencing but on a different page layout as an item of the related list.
User-added image
Any suggestions? Am I entereing the code incorrectly?

how can i create a soql to fetch unique ownerid from Account Object. i don't want to handle this in the code.