You need to sign in to do that
Don't have an account?
Aidel Bruck
How to create a popup message that will show only if certain criteria are met.
When a certain costum object is created and saved I would like a popup message to show only if certain critiria are relevant.
please advice me how to do this
please advice me how to do this
var status={!servrec.Status__c}
with
var status="{!servrec.Status__c}"
Similarly do:
var servicename = "{!servrec.name}";
All Answers
Would you be able to point me towards some code that can do this. I am stil learning the ropes in VF and could use some sample code.
All the best,
Aidel
I am still so confused.
I just need to have a popup that will show if certain critiria are relevant.
I need some sample code for the VF page and the extention. Anybody?
Try the below code, this VF page can be embedded "Inline" into the Account's detail page. It will show an alert if the "Account Number" for an account is null.
Hope this helps.
Best Regards
Veenesh
VF page
***************
<apex:page standardController="Comment__c" extensions="CommentUpdateStageController">
<script>
window.onload = function()
{
var status= {!servrec.Status__c};
var servicename{!servrec.name};
if(status == 'closed' &&servicename.contains('Medical_Directory_Program'))
{
alert('You are adding a comment to a service that is closed. Please change the stage and status accordingly');
}
};
</script>
</apex:page>
extention
************
<apex:page standardController="Comment__c" extensions="CommentUpdateStageController">
<script>
window.onload = function()
{
var status= {!servrec.Status__c};
var servicename{!servrec.name};
if(status == 'closed' &&servicename.contains('Medical_Directory_Program'))
{
alert('You are adding a comment to a service that is closed. Please change the stage and status accordingly');
}
};
</script>
</apex:page>
test
*********
@istest
private class TestCommentUpdateStage
{
public Account a= new account();
public opportunity o= new opportunity();
public opportunity o2= new opportunity();
public comment__C c= new Comment__C();
public comment__C c2= new Comment__C();
static testMethod void myUnitTest()
{
Account a= new account();
opportunity o= new opportunity();
opportunity o2= new opportunity();
comment__C c= new Comment__C();
comment__C c2= new Comment__C();
a= TestDataFactory.createPersonAccount('Cohen');
insert a;
o= testDataFActory.createmedicaldiropportunity(a);
insert o;
o2= testdatafactory.createMedicalBillAssistopportunity(a);
insert o2;
c= testdatafactory.createcomment(o);
c2= testdatafactory.createComment(o2);
insert c;
insert c2;
Test.Starttest();
ApexPages.StandardController stdController = new ApexPages.StandardController(c);
CommentUpdateStageController ext = new CommentUpdateStageController(stdController);
Test.Stoptest();
}
}
public with sharing class CommentUpdateStageController
{
Public id commentId;
public id serviceID;
Public opportunity servRec{get;set;}
Public Comment__C CommentRec{get;set;}
public CommentUpdateStageController(ApexPages.StandardController controller)
{
commentid = ApexPages.currentPage().getParameters().get('id');
if(commentid != null)
commentRec= [select id, Service__c from comment__C where id =:commentId];
if(CommentRec.Service__c!= null)
servRec = [select id,Status__c, stageName, RecordTypeId, name from opportunity where id =:commentRec.Service__c];
}
}
Your solution really worked. The test code runs succesfully.
When I try to get the page to show in salesforce itself nothing happens.
Any idea why this is?
public with sharing class CommentUpdateStageController
{
Public id commentId;
public id serviceID;
Public opportunity servRec{get;set;}
Public Comment__C CommentRec{get;set;}
public CommentUpdateStageController(ApexPages.StandardController controller)
{
commentid = ApexPages.currentPage().getParameters().get('id');
if(commentid != null)
commentRec= [select id, Service__c from comment__C where id =:commentId];
if(CommentRec.Service__c!= null)
servRec = [select id,Status__c, stageName, RecordTypeId, name from opportunity where id =:commentRec.Service__c];
}
}
not seeing any error
I exchanged the code with you code above, And still, Nothing at all doing.
" Uncaught ReferenceError: Closed is not defined "
on the line - var status={!servrec.Status__c}
var status={!servrec.Status__c}
with
var status="{!servrec.Status__c}"
Similarly do:
var servicename = "{!servrec.name}";
I got it to work.