• Balu_SFDC
  • NEWBIE
  • 35 Points
  • Member since 2012
  • Sr Developer
  • NA

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 27
    Replies

hi friends,

i have requirement to prevent dupilcate records on related list (products) which is child for case.

 

I got the duplicate code working fine on the productline object independent of case, however now i want to make it work as part of case since requirment is to prevent duplcate on related list product line.

 

so i need to now check all the products on product line as part of parent object case and then prevent user from entering duplicate, how do i reference case from child object productline?

 

thanks

 

 

 

trigger pp on Product_Line__c (before insert, before update) {
//private list<Case> caseemlist;
//caseemlist=new list<Case>();
Map<String, Product_Line__c> Prodmap = new Map<String, Product_Line__c>();
for (Product_Line__c Pl : System.Trigger.new) {

// Make sure we don't treat an Products__c that
// isn't changing during an update as a duplicate.

if ((Pl.Products__c != null) &&(System.Trigger.isInsert || (Pl.Products__c !=
System.Trigger.oldMap.get(Pl.Id).Products__c)))
{

// Make sure another new Product_Line__c isn't also a duplicate

if (Prodmap.containsKey(Pl.Products__c))
{
Pl.Products__c.addError('Another new Product has the '
+ 'same Products');
} else {
Prodmap.put(Pl.Products__c, Pl);
}
}
}

// Using a single database query, find all the Product_Line__cs in
// the database that have the same Products__c as any
// of the Product_Line__cs being inserted or updated.

for (Product_Line__c Pl : [SELECT Products__c FROM Product_Line__c
WHERE Products__c IN :Prodmap.KeySet()]) {
Product_Line__c newpl = Prodmap.get(Pl.Products__c);
newPl.Products__c.addError('This product '
+ 'already exists.');
}
}

Hi friends,

      

      how can i calculate the total hours for each user, for each month and display in the visulaforce page on the respective columns(like jan,feb...dec).

 

as of now i am just getting the one month results in the page, i need to display all the months results in the same visualforce page.

First i need to get all the owners of the records and display in the first column. one owner is not having any records in any months needs to display 0. 

 

OwnerName#            May                                   June                  July                    Augst ............. December
                                       H          Percent
A                                   5.43     2.95%               
B                                  23.7      12.88%
D                                 1.33       0.72%
H                                139.08    75.59% 
  Grand Total:           626.52
 

Like this i need to get all the months records and display in the page.

My controller

=====================

public class TAC_Effort_reportController{

public decimal grand{get;set;}
public decimal June_grand{get;set;}
public MayEffort[] MayEfforts { get; set; }
public June_Effort[] June_Efforts { get; set; }

public TAC_Effort_reportController(){

//Effort= [select name,Owner.name, Business_Days__c,Hours__c,Minutes__c,Total_in_Hours__c from Effort__C Order By Owner.name];
grand = 0.0;
June_grand=0;

AggregateResult[] results = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs,MAX(Business_Days__c) bd FROM Effort__C where Month_Of_Start_Day__c='5' GROUP BY Owner.Name ];
// AggregateResult[] results_all = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs, MAX(Business_Days__c), Sum(Total_in_Hours__c)/(MAX(Business_Days__c)*8) aggre FROM Effort__C GROUP BY Owner.Name, Month_Of_Start_Day__c];
AggregateResult[] Jan_Results = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs,MAX(Business_Days__c) bd FROM Effort__C where Month_Of_Start_Day__c='1' GROUP BY Owner.Name ];
MayEfforts = new List<MayEffort>();
for (AggregateResult ar : results) {
Grand +=(Decimal) ar.get('Hrs') ;
MayEfforts.add(new MayEffort(ar));
}
for (AggregateResult ar : Jan_Results) {
June_grand +=(Decimal) ar.get('Hrs') ;
June_Efforts.add(new June_Effort(ar));
}
}

// wrapper class to hold aggregate data

public class MayEffort {


public Decimal TotalHours { get; private set; }
public String OwnerName { get; private set; }
public String totalPercent{get;private set;}

public MayEffort(AggregateResult ar) {
TotalHours = (Decimal) ar.get('Hrs');
totalPercent =((TotalHours/(1*8))*100)+'%';

OwnerName = (String) ar.get('o');
}
}

}

====================

VF Page

=====================

<apex:page sidebar="false" controller="TAC_Effort_reportController" showHeader="false" >

<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!MayEfforts}" var="e">
<apex:column headerValue="OwnerName#" style="text-align:center; width:5%" value="{!e.OwnerName}" breakBefore="true" styleClass="colborder"/>
<apex:column headerValue="TotalHours(Hrs & Percent)" style="text-align:center; width:10%" styleClass="colborder" colspan="3" >
<apex:outputtext value="{!e.TotalHours }"/>

<apex:column headerValue="Hourse&Minutes" style="text-align:center; width:10%" styleClass="colborder">
<b><apex:outputField value="{!e.Hours__c}"/> <br/>
<apex:outputField value="{!e.Minutes__c}"/> <br/></b>
</apex:column>

<B>Grand Total:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<apex:outputtext value="{!grand}"/>

</apex:pageblocktable>
</apex:pageBlock>

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

 

please help me on this.

 

Thanks in advance..

balu...

Hi friends,

 

  i have one requirement, i need to generate the monthly(Jan To Dec) report in visulaforce page for the custom object.

For example in my Object, i have 100 records crateded by 10 users. i need to get all the total hours from the each record(Like: 1+2+3=6) and display For each respective owner, and month. all records shold be get based on the month only( here i am getting from the createddate, month).

 

please help me on this.

 

Thanks in advance..

Balu... 

Hi friends,

 

i am trying to customize the standard Lookup to custom look up in the Standard "New" page.

 

when i click on the Lookup Icon it's opening the new custom lookup popup window. here i need to select 3 fields (This is  VF page). and i click on the "Ok" button these 3 fields needs to be papulate in the parent(Standard page) in the 3 fields.

 

how can i can i achive this.. plz help me on this ..it's very Urgent.

 

Thnx

Balu

hi,

i am struggling to write the apex class for the follwing class and vf page..

 

plz can any body do this.........

my apex class is

 

public class search {

public List<student__c> students{get;set;}
public List<student__c> getstudents(){
return students;
}
public student__c getstudent(){
Id id=system.currentpagereference().getparameters().get('id');
return id == null ? new student__c() : [SELECT Id, Name
FROM Student__c
WHERE Id = :id];
}
public String studentname { get; set; }

public String studentId { get; set; }

public PageReference search() {


if(studentId.length()>0)
{
string stdid='select id, name,Student_Name__c,Email_ID__c,Phone_Number__c from student__C where name=:studentId';
students=Database.Query(stdid);
if(students.size()==0)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Student Id Not Found'));
return null;
}
if(studentname.length()>0)
{
string stdname='select id,name,Student_Name__c,Email_ID__c,Phone_Number__c from student__C where student_name__C LIKE \'' + Studentname+ '%\'';
students=Database.Query(stdname);
if(students.size()==0)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Student Name Not Found'));
return null;
}
if((studentId.length()>0)&&(studentname.length()>0))
{
string std='select id,name,Student_Name__c from student__C,Email_ID__c,Phone_Number__c where name=:studentId';
students=Database.Query(std);
return null;
}
else
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Enter Any Value'));
return null;
}
}

}

 

VF page

 

<apex:page controller="search" sidebar="false" tabStyle="search_student__tab">

<apex:sectionHeader title="Search Students"/>
<apex:form >
<script type='text/javascript'>
function noenter(ev) {
if (window.event && window.event.keyCode == 13 || ev.which == 13) {
doSearchAF();
return false;
} else {
return true;
}
}
</script>

<apex:pageBlock title="Search Students Here" onkeypress="return noenter(event)">
<apex:image url="https://ap1.salesforce.com/resource/1350637855000/search" width="90px" height="75px"/>
<center>
<apex:pageblockSection title="Search By Student Id" >
<center>
<apex:inputtext value="{!studentId}" onkeypress="return noenter(event)"/>
</center>
</apex:pageblockSection>
<apex:pageblocksection title="Search by Name">
<center><apex:inputtext value="{!studentname}" onkeypress="return noenter(event)"/>
</center>
</apex:pageblocksection>
<apex:commandButton value="Search" action="{!search}" reRender="pgb,pmsgs"/>
</center>
<apex:pagemessages id="pmsgs"/>
<apex:pageblocktable value="{!students}" var="s" id="pgb">
<apex:column >
<apex:commandLink reRender="detail">{!s.name}
<apex:param name="id" value="{!s.id}"/>
</apex:commandLink>

</apex:column>
<apex:column value="{!s.First_Name__c}"/>
<apex:column value="{!s.Email_ID__c}"/>
<apex:column value="{!s.Phone_Number__c}"/>
</apex:pageblocktable>
<apex:actionFunction name="doSearchAF" action="{!Search}" />
</apex:pageBlock>
</apex:form>
<apex:outputpanel id="detail">
<apex:detail subject="{!student}" title="false" relatedList="false"/>
</apex:outputpanel>

</apex:page>

 

 

Thanks in advance........

 

Regards.....

Balu

 

 

Hi everyone,,

 

I am trying write the test method for the follwing apex class..

i am get 28% of code coverage..please help in this......for getting more than 75% code coverage..

.

My apex class is::

public class search {

public List<student__c> students{get;set;}
public List<student__c> getstudents(){
return students;
}
public student__c getstudent(){
Id id=system.currentpagereference().getparameters().get('id');
return id == null ? new student__c() : [SELECT Id, Name
FROM Student__c
WHERE Id = :id];
}
public String studentname { get; set; }

public String studentId { get; set; }

public PageReference search() {


if(studentId.length()>0)
{
string stdid='select id, name,Student_Name__c,Email_ID__c,Phone_Number__c from student__C where name=:studentId';
students=Database.Query(stdid);
if(students.size()==0)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Student Id Not Found'));
return null;
}
if(studentname.length()>0)
{
string stdname='select id,name,Student_Name__c,Email_ID__c,Phone_Number__c from student__C where student_name__C LIKE \'' + Studentname+ '%\'';
students=Database.Query(stdname);
if(students.size()==0)
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Student Name Not Found'));
return null;
}
if((studentId.length()>0)&&(studentname.length()>0))
{
string std='select id,name,Student_Name__c from student__C,Email_ID__c,Phone_Number__c where name=:studentId';
students=Database.Query(std);
return null;
}
else
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please Enter Any Value'));
return null;
}
}
}

 

Test Class

 

@istest
public class testMyPage {
static testMethod void myPage_Test()
{
//Test converage for the myPage visualforce page
PageReference pageRef = Page.search_student;
Test.setCurrentPageReference(pageRef);
// create an instance of the controller
search myPageCon = new search();
//try calling methods/properties of the controller in all possible scenarios
// to get the best coverage.
List<student__c> std = myPageCon.getstudents();
//test when type == null
myPageCon.search();
mypagecon.studentname='b';
myPageCon.getstudents();
}
}

thanks in advance........

 

Regards.

Balu

hi.....

i integrated with Facebook...now i want to give the comment to the post from my VF Page...

how can we achive this......

 here is the some code

VF Page

<apex:page controller="FacebookSampleController" action="{!login}"
cache="false" sidebar="false" showHeader="false"
title="Force.com Toolkit for Facebook - Sample Page">
<apex:stylesheet value="{!URLFOR($Resource.style)}"/>
<script src="{!$Resource.jquery}"></script>
<script src="{!$Resource.html_sanitizer}"></script>
<script>
var $j = jQuery.noConflict();

function getFriends() {
// Show the throbber
$j("#friends").html('<img src="{!$Resource.ajax}" width="16" height="11"/>');

// The remote method can't get the access token via the cookie, so we
// get it from an action method and pass it here
FacebookSampleController.getFriends('{!accessToken}', function(result, event) {
if (event.status) {
// result comes back escaped - use Caja to unescape it
var json = html.unescapeEntities(result);
var friends = JSON.parse(json);
// Truncate the array to a maximum of 10 friends
friends.data.length = Math.min(10, friends.data.length);
$j("#friends").html('<pre>'+JSON.stringify(friends, null, ' ')+'</pre>');
} else {
alert(event.message + '\n' + JSON.stringify(event));
}
});
}

function showUserDataThrobber() {
$j("#user").html('<img src="{!$Resource.ajax}" width="16" height="11"/>');
}
</script>
<h1>Force.com Toolkit for Facebook</h1>
<br/>
<br/>
<h2>Sample Page</h2>&nbsp;&nbsp;<apex:outputLink value="FacebookTestUser">Test User Connections</apex:outputLink>
<p>This page shows you how to use the Force.com Toolkit for Facebook.</p>

<h2>{!me.name}</h2>
<br/>
<c:FacebookProfilePicture fbid="{!me.id}" width="120" height="120" type="large"/>
<br/>
<br/>

<h2>Status</h2>
<apex:form >
<apex:inputText value="{!message}" id="message"/>&nbsp;&nbsp;
<apex:commandButton value="Post" action="{!postToFeed}" rerender="posts"/>
</apex:form>
<br/>

<apex:form >
<h2>Your Feed</h2>&nbsp;&nbsp;<apex:commandButton value="Refresh" rerender="posts"/>
<apex:outputPanel id="posts">
<br/><apex:outputText value="{!error}" />
<apex:dataTable value="{!myPosts.data}" var="post" cellpadding="5">
<apex:column style="vertical-align:top;">
<c:FacebookProfilePicture fbid="{!post.from_z.id}" width="60" height="60" />
</apex:column>
<apex:column >
<b>{!post.from_z.name}</b><br/>
{!post.message}<br/>
{!post.story}<br/>
{!post.created_time}<br/>
{!post.likes.count}{!IF(ISBLANK(post.likes), "", IF((post.likes.count == 1), " Like ", " Likes "))}
<apex:commandLink value="Delete" action="{!deletePost}" rerender="posts">
<apex:param name="postId" value="{!post.id}" assignTo="{!postId}"/>
</apex:commandLink>
<br/>
<apex:inputText value="{!message1}" id="message"/>&nbsp;&nbsp;
&nbsp;&nbsp;
<apex:commandbutton value="reply" action="{!postToReply}" rerender="posts">
<apex:param name="ReplyId" value="{!post.id}" assignTo="{!replyId}"/>
</apex:commandbutton>

<apex:dataTable value="{!post.comments.data}" var="comment" cellpadding="5">
<apex:column style="vertical-align:top;">
<c:FacebookProfilePicture fbid="{!comment.from_z.id}" width="40" height="40" type="small"/>
</apex:column>
<apex:column >
<b>{!comment.from_z.name}</b><br/>
{!comment.message}<br/>
{!comment.created_time}<br/>
{!comment.likes}{!IF(ISBLANK(comment.likes), "", IF((comment.likes == 1), " Like", " Likes"))}
<apex:commandLink value="Reply" action="{!postToReply}" reRender="posts" >
<apex:param name="replyId" value="{!comment.id}" assignTo="{!replyId}"/>
</apex:commandLink>&nbsp;&nbsp;
<apex:commandLink value="delete" action="{!deletecmt}" reRender="posts">
<apex:param name="cmtId" value="{!comment.id}" assignTo="{!cmtId}"/>
</apex:commandlink>
</apex:column>
</apex:dataTable>
</apex:column>
</apex:dataTable>
</apex:outputPanel>
</apex:form>
<hr/>

<h2>Your user record in JSON (via action method):</h2>
<apex:form >
<apex:commandButton value="Get It Now!" onclick="showUserDataThrobber();" action="{!getUserData}" rerender="userPanel"/>
</apex:form>
<apex:outputPanel id="userPanel">
<script>
// Use a little JavaScript to pretty print the JSON
var user = {!facebookUser};
$j("#user").html('<pre>'+JSON.stringify(user, null, ' ')+'</pre>');
</script>
<pre id="user"></pre>
</apex:outputPanel>
<hr/>

<h2>10 of your friends in JSON (via JS remoting):</h2>
<br/>
<input type="submit" class="btn" onclick="getFriends();" value="Get Them Now!"/>
<pre id="friends"></pre>

<hr/>
(Note: the following tags are intended to be used on a sites page in order to get the correct share url. To view them correctly, expose this page as a sites page)
<p>Facebook like tag:</p>
<c:FacebookLike />

<p>Facebook recommendations tag:</p>
<c:FacebookRecommendations />

<p>Facebook Activities tag:</p>
<c:FacebookActivity />
</apex:page>

-----------------------

Apex Class

-------------------

/**
* @author Pat Patterson - ppatterson@salesforce.com
*/

global with sharing class FacebookSampleController extends FacebookLoginController {
// Set this to an auth provider id (e.g. '0SOD00000000012') to use an
// auth provider (new in Spring '12)
private static String authProviderId = null;

public String message {get; set;}
public String message1 {get; set;}
public String postId {get; set;}
public string cmtId{get;set;}
public String userData {get; set;}
public String error {get; set;}
public String messageId{get;set;}
public string replyId{get;set;}
public FacebookSampleController() {
userData = 'null';
}

// You wouldn't usually need to override login(). We do here to be able
// to change the behavior depending on whether we want to use the platform
// auth provider. If you want to use the auth provider in your controller,
// just don't extend FacebookLoginController
public override PageReference login() {
return ( authProviderId == null ) ? super.login() : null;
}

public static String getAccessToken() {
return ( authProviderId == null )
? FacebookToken.getAccessToken()
: Auth.AuthToken.getAccessToken(authProviderId, 'facebook');
}

public FacebookUser me {
get {
try {
// Can't set up 'me' in the controller constructor, since the superclass
// 'login' method won't have been called!
if (me == null) {
String accessToken = getAccessToken();

// If accessToken is null, it's likely that the page's action
// method has not yet been called, so we haven't been to FB to
// get an access token yet. If this is the case, we can just
// leave 'me' as null, since the redirect will happen before
// HTML is send back.
if (accessToken != null) {
me = new FacebookUser(accessToken, 'me');
}
}
} catch (Exception e) {
error = e.getMessage();
}

return me;
} set;
}

public FacebookPosts myPosts {
get {
try {
String accessToken = getAccessToken();

if (accessToken != null) {
myPosts = new FacebookPosts(accessToken, 'me/feed', null);
}
} catch (Exception e) {
error = e.getMessage();
}

return myPosts;
} set;
}

// Returns JSON string with user info
public String getFacebookUser() {
return userData;
}

public PageReference getUserData() {
error = null;

try {
userData = FacebookUtil.get(getAccessToken(), 'me');
} catch (Exception e) {
error = e.getMessage();
}

return null;
}

// Can't get the cookies in a remote method, so pass it in explicitly
@RemoteAction
global static String getFriends(String accessToken) {
String friends = null;

try {
friends = FacebookUtil.get(accessToken, 'me/friends');
} catch (Exception e) {
// Can't set the error message in a static method, so let's
// just return it
friends = e.getMessage();
}

return friends;
}

public PageReference postToFeed() {
error = null;

try {
if (message != null) {
FacebookPublish.postToWall(getAccessToken(), 'me', new Map<String, String>{'message' => message});
}

message = null;
} catch (Exception e) {
error = e.getMessage();
}

return null;
}
public PageReference postToReply() {
error = null;

try {

if(message1 != null)
{

FacebookPublish.postcomment(getAccessToken(),this.replyId,new Map<String, String>{'message' => message1});

}

message1 = null;

} catch (Exception e) {
error = e.getMessage();
}

return null;

}
public PageReference deletePost() {
error = null;

try {
if (postId != null) {
FacebookUtil.deleteItem(getAccessToken(), postId);
}

postId = null;
} catch (Exception e) {
error = e.getMessage();
}

return null;
}

public PageReference deletecmt() {
error = null;

try {
if (cmtId != null) {
FacebookUtil.deleteItem(getAccessToken(), cmtId);
}

cmtId = null;
} catch (Exception e) {
error = e.getMessage();
}

return null;
}

static testMethod void testController() {
// TODO
}
}

 

plz give the reply......

thanks in advance..........

 

Regards........

Balu

Hi,

i installed facebook integration from the appexchange APIVersion3...in that we have sample VF page.

in this sameplepage we can post our status and also get the comments for that status..

now i want to give the reply for that comment from the VF Page(Salesforce)...

how can i achive this plz give me reply...

 

 

Thanks in advance.......

Balu

Hi everyone.....

i am new to the apex Test class..so plz help me on for writing the test class for below code

 

trigger autonumber1 on Account (before insert)
{
  for(account a:trigger.new)
  {
  
    List<account> ac=[select autonumber__c from account];
 if(ac[0].autonumber__c!=null)
  {
  a.autonumber__c=ac[0].autonumber__c+1;    
   }
   else
   a.autonumber__c=1200;
}
}

 

i am getting 60% code coverage but i got the failure message like...

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, autonumber1: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0 Trigger.autonumber1: line 7, column 1: []

 

 

thanks in advance...

 

 

 

 

Need to write a test class for the below REST class.
public class callApi {
    public String Response;
	public String apiKey;
	List<String> prospectValues = new List<String>();
    public PardotProspectWrapper wrapper {get; set;}
    public List<PardotProspectWrapper> wrapperList {get;set;}
    public List<Pardot_Prospect__c> ppobjlst {get;set;}
    //getting values from customSetting
            SFtoPardot__c pdcred = SFtoPardot__c.getInstance('PardotCredentials');
	        String email = pdcred.PardotUserName__c;
            String password = pdcred.PardotPassword__c;
            String userKey = pdcred.API_User_Key__c;
            String CreatedAfter = pdcred.Created_After__c;
            String CreatedBefore = pdcred.Created_Before__c;
			
     //Declaring wrapper for custom object Pardot_Prospect__c
	 Pardot_Prospect__c PP = new Pardot_Prospect__c();
    
    //Authenticating Pardot with Salesforce
    public void Auth() {
		    HttpRequest req = new HttpRequest();
            req.setEndpoint( 'https://pi.pardot.com/api/login/version/4' );
            req.setMethod( 'POST' );
            req.setBody( 'email=' + email + '&password=' + password + '&user_key=' + userKey );
            
            HttpResponse res = new Http().send( req );
			
		    String response = res.getBody();
            Integer startIdx = response.indexOf( '<api_key>' ) + 9;
            Integer endIdx = response.indexOf( '</api_key>' );
            String apiKey = response.substring( startIdx, endIdx );
	        System.debug('******'+apiKey );
			getAndParse(apiKey,userKey);
        }
	
    //Getting and Parsing the response received from Pardot
	public void getAndParse(String apiKey, String userKey){
		   HttpRequest req = new HttpRequest();
           HttpResponse res = new HttpResponse();
           req.setEndpoint( 'https://pi.pardot.com/api/prospect/version/4/do/query?user_key='+userKey+'&'+'api_key='+apiKey+'&'+'output=bulk&format=json&created_after='+CreatedAfter+'&'+'created_before='+CreatedBefore+'&'+'sort_by=created_at&sort_order=ascending');
           req.setMethod( 'GET' );
           req.setBody( 'user_key='+userKey+'&'+'api_key='+apiKey);
           req.setHeader('Accept', 'application/json ');
           req.setHeader('Content-Type','application/json');
		   res = new Http().send( req );
	       System.debug('***Response****'+res.getBody());
           wrapper = (PardotProspectWrapper)JSON.deserialize(res.getBody(), PardotProspectWrapper.class);
          system.debug('******Wrapper*****'+wrapper);
        
            //this I tried to add to store the data in Pardot_Prospect__c 
			ppobjlst = new List<Pardot_Prospect__c>();
           Pardot_Prospect__c ppobj = new Pardot_Prospect__c();
			for (PardotProspectWrapper.prospect p : wrapper.result.prospect) {
                ppobj = new Pardot_Prospect__c();
                ppobj.Prospect_Id__c = string.valueOf(p.id);
                ppobj.First_name__c = p.first_name;
                ppobj.Last_Name__c = p.last_name;
                ppobj.Company__c = p.company;
                ppobj.Grade__c = p.grade;
                ppobj.Score__c = p.score;
				ppobjlst.add(ppobj);
			}
			insert ppobjlst;     
		}    
    
    }

 
testItemList = [SELECT Id, Right__c, Percent_correct_answers__c FROM Session__c WHERE Id =:SessionId];
        //update field Answer for Session
        if (newItem[0].Answer__c == answer) {
            answerCount++;
            testItemList[0].Right__c=answerCount;
            update testItemList;
            
        }

 
Hi all,
I m stuck to create a link for my attachment in Account 

<apex:outputlink value="/servlet/servlet.FileDownload?file={!Attachment.id}" target="_blank">View</apex:outputlink>

Could you please help me ? 
​​​​​​​Thanks
Hello All,

I am validating on field as format ,any numeric and alpha numeric(4) then (-) again any numeric and alpha numeric(5)
Eg. AA12-A322R
 
NOT(REGEX(CurrentGenerators__c,"[a-zA-Z0-9]{4}[-][a-zA-Z0-9]{5}"))
Regards,
Dinesh
  • September 19, 2018
  • Like
  • 0
we will have a dropdown with the names here will be a Email button which will only become enabled once a dropdown value is selected.

Hi, can anyone can help me, I have little experience with apex trigger, I need to create a record base on the OpportunityLineItem custom field.

Multiple Records to create:

Campaign_Scorecard__c - custom object - Look-up relationship with Opportunity.

Here is my code
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://api.geonames.org/countryCode?lat=52.42452&lng=10.7815&username=***');
        req.setHeader('Content-Type', 'text/html');
        req.setMethod('GET');
HttpResponse res = h.send(req);
 System.debug('country' + res.getBody()); ( return 'DE' as result)
 String Country = (String)res.getBody();
System.debug('the return value is'+Country); ( 'DE' as result )

ISOContry__c cs = ISOContry__c.getInstance(Country);
System.debug(cs); ( return null as result)
System.debug (' the A3 '+ cs.A3__c); ( Attempt to de-reference a null object)



      But when I try just to give the value as String  it is working so that's mean that the custom setting has the name 'DE' ! so really I don't understand what could be the problem

ISOContry__c cs2= ISOContry__c.getInstance('DE');
System.debug(cs2.A3__c); (it is working as expected)

 
  • September 19, 2018
  • Like
  • 0
Hi all,

Here is my code:
<apex:page standardController="Student__c" extensions="GenerateCSV" action="{!generate}" cache="true" contentType="text/csv#{!exportFileName}" language="en-US">
    <script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
    <script type="text/javascript">
        Sfdc.onReady(function(){
            alert('onReady');
        });
    </script>
    <apex:outputText value="{!exportStr}"/>
</apex:page>

Here the alert is not getting executed. If I remove contentType property it works fine. But, I need even that. All I need is to execute javascript after downloading a CSV file. Please help!!
Hi, I have a very simple button that sends infomation to a webservice.

What I'm trying to do is have an if / else statement that will display an alert with whether the submission was a success or failure.

The code is really quite simple, but it's displaying the wrong alert on a record that I know is a success and a record that I know fails.

Here's the code (note the first alert is just so I can see the inital response from the webservice

If it's a Success, it will return 

User-added image

If it fails, it will return

User-added image
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

var json = sforce.apex.execute("ItsApprovedWebServices","GetBookingDetails",{id:"{!ItsApproved_Booking__c.Id}"});

var authorizationToken = sforce.apex.execute("ItsApprovedWebServices","Login",{userName: 'xxxx'});

var result = sforce.apex.execute("ItsApprovedWebServices","PostBooking",{json: json, authorizationToken: authorizationToken});

alert(result); //if correct returns "Success", if incorrect, returns a long error message

if (result == "Success") {
alert("OK, Booking sent to ItsApproved - http:www.google.com");
}
else { 
alert("Error! Call Cestrian and quote '{!ItsApproved_Booking__c.Name}'");
}
I'm getting the second alert for both scenarios.

What could be wrong in the code?
 
My scenario is to create a Custom button in Account object while clicking that button it show some required field in Case their I want to add submit custom button after clicking that it will create a case record from that account.

I am pretty new to Salesforce development. Can anyone give me suggestion to do this.

Thanks in Advance.
I have a need to be able to recreate the 'Save & Send Update' button functionality on the event screen in APex Code, can anyone help with a code snippet on how to do this please.

Basically I want to have an automated process that monthly creates an 'Event' and then sends out a Meeting invite to all the Invitees.  I particularly want the email functionality that has the 'Respond to This Request' button in the email.

Does anyone know what code is run when the 'Save & Send Update' button is pressed?

Thanks in advance.


  • January 21, 2014
  • Like
  • 0

Hi All,

 

I need to open a link in a new window using <apex:outputLink>.I set target="_blank".am using Google Chrome.While I click the link,the page is opened in a new tab.But,I need to open it in a new window.Please help me to find a solution.

 

Thanks in advance.

 

 

hi friends,

i have requirement to prevent dupilcate records on related list (products) which is child for case.

 

I got the duplicate code working fine on the productline object independent of case, however now i want to make it work as part of case since requirment is to prevent duplcate on related list product line.

 

so i need to now check all the products on product line as part of parent object case and then prevent user from entering duplicate, how do i reference case from child object productline?

 

thanks

 

 

 

trigger pp on Product_Line__c (before insert, before update) {
//private list<Case> caseemlist;
//caseemlist=new list<Case>();
Map<String, Product_Line__c> Prodmap = new Map<String, Product_Line__c>();
for (Product_Line__c Pl : System.Trigger.new) {

// Make sure we don't treat an Products__c that
// isn't changing during an update as a duplicate.

if ((Pl.Products__c != null) &&(System.Trigger.isInsert || (Pl.Products__c !=
System.Trigger.oldMap.get(Pl.Id).Products__c)))
{

// Make sure another new Product_Line__c isn't also a duplicate

if (Prodmap.containsKey(Pl.Products__c))
{
Pl.Products__c.addError('Another new Product has the '
+ 'same Products');
} else {
Prodmap.put(Pl.Products__c, Pl);
}
}
}

// Using a single database query, find all the Product_Line__cs in
// the database that have the same Products__c as any
// of the Product_Line__cs being inserted or updated.

for (Product_Line__c Pl : [SELECT Products__c FROM Product_Line__c
WHERE Products__c IN :Prodmap.KeySet()]) {
Product_Line__c newpl = Prodmap.get(Pl.Products__c);
newPl.Products__c.addError('This product '
+ 'already exists.');
}
}

Hello Friends,

 

Hope You all are doing good.....I have little problem with one of the trigger I am working on....Please help me becuase I don't kno what to do....

 

Objective: To build an error management email to "custom object" 
feature.

Requirement: Whenever an error occurs during either an upsert function
or response (call-out) function in the Skyvva framework, we need an
email to be sent and also a case (request) record to be created in a
custom object called "SFDC User Requests
 in our SFDC Org. This required feature should be similar to a standard email to case feature.

Reason not to use the standard email to case feature: We do not use the
standard case object to create cases/ tickets related to Salesforce
requests and issues. Instead we use a custom object called "SFDC User
Requests."

 

Here the Trigger I wrote....

trigger trgMessage on skyvvasolutions__IMessage__c (after update) {

List<Salesforce_User_Request__c> lSFUserRequest = new List<Salesforce_User_Request__c>();

 for(skyvvasolutions__IMessage__c msg: Trigger.New){

        //populate value of failed message to custom object and add to list

        if(msg.skyvvasolutions__Status__c=='Failed'){

            lSFUserRequest.add(new Salesforce_User_Request__c(

                //assign value from skyvvasolutions__IMessage__c to custom object         
                   // Status__c = 'New',
                    Name = msg.skyvvasolutions__Target__c,
                    Salesforce_Request_Details__c = msg.skyvvasolutions__Comment__c
                   // Types_of_User_Requests__c = msg.skyvvasolutions__Type__c
                    
                   ));

            }

    }
     //insert, if external Id is specify external Id, you can upsert external_Id__c
   if(lSFUserRequest.size()>0)
    {
            insert lSFUserRequest;

    }
}

 

The problem is that when we are testing it from Skyvva framework It creates two records on The Custom Object, first I thought becuase of workflow but I deactivated the workflow and it is still creating two records I dont know what to do ...

 

Please let me know the perfect solution.. Thanks in advance.........