• street
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 65
    Questions
  • 76
    Replies

Check/ DD date should be kept equal or greater than Receipt date.

 

Check_DD_Date__c >= Receipt_Date__c

 

Its not working validation rule.

HI

I had wrote a trigger .it is working fine but now i want to bulkify my trigger...please help me to bulkification.

I am sending thte trigger . 

please help me for bulkification.....thanks in advance

Trigger:

----------------------
trigger UpdateTenantAllocation on Tenant_Allocations__c (after update)
 {
 public list<Invoice_and_Billing_Detail__c> INVBD {get;set;}
INVBD  = new List<Invoice_and_Billing_Detail__c>();
for(Tenant_Allocations__c t:trigger.new)
{
Location__c  l1=[select id,Bill_Tenants__c from location__c where id=:t.Location_new__c];
system.debug('............'+l1);
Invoice_and_Billing_Detail__c[] lb=[select id,Rate__c, name,Location1__c from Invoice_and_Billing_Detail__c where Location1__c=:l1.id and QB_Txn_ID__c=null ]; 
system.debug('............'+lb);
for(Invoice_and_Billing_Detail__c lb1:lb){
if(l1.Bill_Tenants__c==true)
{
lb1.Rate__c=t.Next_Period_Invoice_Amount__c;
}
else 
{
lb1.Rate__c=222;
}
 INVBD.add(lb1);
}
update  INVBD;
system.debug('............'+lb);
}
}

I have  a field on Visualforce page( Buying)which contains Amount for eg: 300rps values in rupees.

 

Now there is a field(Enter amount) on same page(buying)

where the amount to be to entered in it and submit..

Now there should be condition checking on pagelevel that Enter amount field should be less than Amount.

  

I need this to check on page Enter amount <= amount

 

HOw can i check on page itself. tried action support using onchange on field Enter amount.

 

Any help will be thankfull.

How to call inputfield value which is in page block from javascript.

 

function test()

{

var end_date=document.getElementById(ttt);

}

 

 

<apex:column headerValue="Value1" id="e">

<apex:inputfield id="ttt" value="{!Is_rate}" >
</apex:inputfield>

how to remove the toolbar from homecomponent. i have uploaded homecomponent  to production then under the page the code toolbar is also appearing..........how to remove that any suggestions!!!!

I have a picklist with values

 

1) open

2) None

 

only the admin or developer Profile can select picklist value "None" then the picklist has to update the picklist, all other profiles if selects "None" sholud rise the validation error.

trigger Assert_Creation on OpportunityLineItem (after insert)
 {
 for(OpportunityLineItem oli:trigger.new)
 {
 opportunity o=[select id,Accountid,Name,Manager__r.name,Sales_Consultan__r.name,Sales_Consultan__c,
                       Process_Consultant_User__r.name,Process_Consultant_Manager__r.name,
                       Branch__c,Payment_Option__c,Sales_Date__c,Process_Stage__c from opportunity where id=:oli.opportunityid];

 asset a=new asset();
 a.name=o.name;

 a.Accountid=o.Accountid;
 a.Sales_Consultant1__c=o.Sales_Consultan__c;
 a.Sales_Consultant_Manager1__c=o.Manager__c;
 a.Process_Consultant1__c=o.Process_Consultant_User__c;
 a.Process_Consultant_Manager1__c=o.Process_Consultant_Manager__c;
 a.Branch__c=o.Branch__c;
 a.Payment_Option__c=o.Payment_Option__c;
 a.Expected_Sale_Date__c=o.Sales_Date__c;
 a.Process_Stage__c=o.Process_Stage__c;
 a.opportunity__c=o.id;

 insert a; 
 }
 }


I have written Like this 

@isTest
private class Assert_Creation_TC {
static testMethod void validateabc() {
Branch__c b= new Branch__c();
b.Name='sdf';
b.Branch_Code__c='xc';
b.City__c='df';
b.City__c='ww';
b.Pin_Code__c='wewe';
b.Invoice_Number_Cash__c=23;
b.Invoice_Number_General__c=23;
b.Invoice_Number_Online__c=23;
insert b;


account a= new account();
a.name='dsad';
insert a;
user u = [select id from user limit 1];

 


//Pricebook2 standardPB = [select id from Pricebook2 limit 1];


Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
insert pb;
Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);

PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id,Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
insert pbe;

 

opportunity o = new opportunity();
o.Name='ssd';
o.CloseDate=date.ValueOf('2011-09-21');
o.Branch__c=b.id;
o.Manager__c=u.id;
o.Payment_Option__c='Full Payment';
o.StageName='Follow up for Evaluation';
o.Accountid=a.id;

insert o;
update o;

opportunitylineitem op=new opportunitylineitem();
op.Quantity=1;
op.UnitPrice=76;
op.OpportunityId=o.id;
op.PricebookEntryId = pbe.id;
insert op;


asset ass=new asset();
ass.name=o.name;

}
}

 

Here is the error:

Method NameTotal Time (ms)MessageStack Trace

Assert_Creation_TC.validateabc461.0System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Product2Id]: [Product2Id]Class.Assert_Creation_TC.validateabc: line 32, column 1

trigger Update_Actualtime_Projecttask on Timesheet__c(after insert, after update)
{
for(Timesheet__c t:trigger.new)
{
Project_Task__c p =[select id,Project__c , Actual_Time__c from Project_Task__c where id=:t.Project_Task__c and project__c=:t.project__c];
Timesheet__c[] t1=[select id,Effort_in_hours__c from Timesheet__c where project__c =:p.project__c and Project_Task__c =:p.id];
Decimal id2num =0.0;
p.Actual_Time__c=0;
for(Timesheet__c t2:t1)
{
id2num =t2.Effort_in_hours__c + id2num;
p.Actual_Time__c = id2num;
update p;
}
}
}

 

 

bulkification of the trigger

I have trigger where i need to check a Multi select picklist value if it contains Value Temporary then the value has to update by entering into If() Condition as shown below.

 

trigger Update_Candidate_TempLocation on Contact (before insert,before update)
{
for(Contact c:trigger.new)
{
if(c.Candidate_Position_Type_IDs_New__c=='temporary' && c.RecordTypeid=='012D0000000hW06')
{
c.Candidate_Temp_Location_New__c=c.MailingState ;
}

}

}

 

This is my code. How to look into it, if multi select picklist contains Temporary!!!

 

 


This is trigger:

 

trigger placement_enddate on AVTRRT__Placement__c (before insert) {

for(AVTRRT__Placement__c plc:trigger.new)
 {
AVTRRT__Job_Applicant__c japp=[select AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c from AVTRRT__Job_Applicant__c where id=:plc.AVTRRT__Job_Applicant__c ];
plc.AVTRRT__End_Date__c =japp.AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c;

}
}

 

 

Here Is the Testcase below:

 

@isTest
private class placement_enddate_TC
{

static testMethod void myUnitTest()
{

Profile p = [select id from profile where name='Standard User'];

User u = new User(alias = 'standt', email='standarduser@testorg.com',

emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',

localesidkey='en_US', profileid = p.Id,

timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');


account acct=new account();
acct.Name='Test account';
insert acct;

 

AVTRRT__Job__c jb=new AVTRRT__Job__c();
jb.AVTRRT__Job_Title__c='Test Functional';

jb.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert jb;    // Showing error here while running the testcase!!!

 

contact ct=new contact();
ct.RecordType.id = '012D0000000hW06';
ct.LastName='test candidate';
insert ct;


AVTRRT__Job_Applicant__c ja=new AVTRRT__Job_Applicant__c();
ja.AVTRRT__Job__c=jb.id;
ja.AVTRRT__Contact_Candidate__c=ct.id;
insert ja;

AVTRRT__Placement__c a=new AVTRRT__Placement__c();
a.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert a;
}}

 

Method NameTotal Time (ms)MessageStack Trace

placement_enddate_TC.myUnitTest234.0System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AVTRRT.Trigger_Job: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object (AVTRRT): []Class.placement_enddate_TC.myUnitTest: line 28, column 1

global class bitly {

Public String mode;
Public String sUrl;

public String getbitly () {
String shorten;
XmlStreamReader reader;
HttpResponse res;

//First, build the http request
Http h = new Http();
HttpRequest req = buildWebServiceRequest(sURL);

//Second, invoke web service call
if (mode=='live') { res = invokeWebService(h, req); }

if (mode=='live') { reader = res.getXmlStreamReader(); }
else
{
String str = '<bitly><results shortUrl="http://bit.ly/QqHEm">Foo bar</results></bitly>';
reader = new XmlStreamReader(str);
}
return readXMLResponse(reader,'shortUrl');

}


public static HttpRequest buildWebServiceRequest(String purl){
String endpoint;
HttpRequest req = new HttpRequest();
endpoint = 'http://api.bitly.com/shorten?version=2.0.1&format=xml&history=1&longUrl=' + purl + '&login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e';
req.setEndpoint(endpoint);
req.setMethod('GET');
return req;
}

public static HttpResponse invokeWebService(Http h, HttpRequest req){

//Invoke Web Service
HttpResponse res = h.send(req);
return res;
}


public static String readXMLResponse(XmlStreamReader reader, String sxmltag){
string retValue;
// Read through the XML
system.debug(reader.toString());
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName() == sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
}
}
}
reader.next();
}
return retValue;
}


}

I want use below code..

global class bitly {

Public String mode;
Public String sUrl;

public String getbitly () {
String shorten;
XmlStreamReader reader;
HttpResponse res;

//First, build the http request
Http h = new Http();
HttpRequest req = buildWebServiceRequest(sURL);

//Second, invoke web service call
if (mode=='live') { res = invokeWebService(h, req); }

if (mode=='live') { reader = res.getXmlStreamReader(); }
else
{
String str = '<bitly><results shortUrl="http://bit.ly/QqHEm">Foo bar</results></bitly>';
reader = new XmlStreamReader(str);
}
return readXMLResponse(reader,'shortUrl');

}


public static HttpRequest buildWebServiceRequest(String purl){
String endpoint;
HttpRequest req = new HttpRequest();
endpoint = 'http://api.bit.ly/shorten?version=2.0.1&format=xml&history=1&longUrl=' + purl + '&login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e';
req.setEndpoint(endpoint);
req.setMethod('GET');
return req;
}

public static HttpResponse invokeWebService(Http h, HttpRequest req){

//Invoke Web Service
HttpResponse res = h.send(req);
return res;
}


public static String readXMLResponse(XmlStreamReader reader, String sxmltag){
string retValue;
// Read through the XML
system.debug(reader.toString());
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName() == sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
}
}
}
reader.next();
}
return retValue;
}


}

bitly b = new bitly();
b.mode = 'live';
b.sUrl = 'http://www.bridgefarmconsulting.com';

system.debug('Check BitLy' + b.getbitly() );
Im using above code it giving error at endpoint. what to be changed their.

How can i create a formula field where it sholud get value from a multiselectpicklist.

 

Any help!!

I want to embed javascript coding in visualforce. The javascript coding is for integrating 'Bitly' platform with salesforce.

 

My visualforce code is:

 

<apex:form >
<apex:inputText value="{!Candidate__c.Long_Url__c}" id="theText" onclick="javascript&colon;go('{!$Component.theText}')" ></apex:inputText>

  <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/11.1/connection.js"></script>
    
   <script language="javascript">
    
   function go(f) {
    var theText = document.getElementById(f).value;
   alert(theText);
   }
var xhr = new XMLHttpRequest(); 

xhr.open("GET", "http://api.bitly.com//v3/shorten?login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e&longUrl="+theText);

xhr.onreadystatechange = function(){ 

alert('test');
if(xhr.readyState == 4) { 
if(xhr.status==200) { 
var jsonResponse = JSON.parse(xhr.responseText);
var bitlyUrl = jsonResponse.data.url; 

myFunc(bitlyUrl);
var t = xhr.send();
}
}
}

</script>
</apex:form>
<apex:form >
<apex:actionFunction name="myFunc" action="{!field}">
<apex:param name="param1" value=""/>
</apex:actionFunction>
</apex:form>

</apex:page>

 

Bitly is used for URL shortening. I want the shortened url to be passed to the controller through <apex:actionfunction>.

 

Please help. Its really urgent. I am completely stuck.

 

Thanks

 

 

Hi everyone i have a list in my Apex class which has soql query result..

        

String query = 'SELECT  City,Latitude__c FROM Lead WHERE City LIKE \''+city+'%\'';
       
        leadrecords = Database.query(query);   

 

Eg :in the above line leadrecords is alist of lead type

 

    private List<Lead> leadrecords;

 

So now iam trying to pass this list to ajavascript variable so dat javascript variable should have query  output...but when i have done like this iam able to pass the list but when iam tryong to display that it is displaying the  ids  but i want to display the field city and latitude which are storesd in that list how to do it please someone help me with the solution... to javascript variable so how to pass this list to javascript variable

  

hi,

I'm trying to create a test class for a trigger:

 

trigger deleteTask on OpportunityLineItem (before delete) {

List<OpportunityLineItem> OppLIs = Trigger.old;
List<Task> tasks = new List<Task>();

for (OpportunityLineItem OppLI : OppLIs) {

Opportunity Opp = [ Select OwnerId from Opportunity where id=:OppLI.OpportunityId limit 1 ];
User usuario = [ Select Sociedad__c from User where id=:Opp.OwnerId ];

//el usuario debe pertenecer a argentina = usuario.Sociedad__c == 1000
if ( usuario.Sociedad__c == '1000' ) {
tasks = [ Select Id from Task where whatID=:OppLI.OpportunityId and Subject='Recordatorio: Vencimiento de producto'];
}
}

delete tasks;

}

 

My test class is:

 

@isTest
private class deleteTaskTest {

static testMethod void myUnitTest() {

//Create a custom pricebook
Pricebook2 pb = new Pricebook2(Name='Custom Pricebok',IsActive=true);
insert pb;

// Create a new product
Product2 prod = new Product2(IsActive=true, Name='Product');
insert prod;

// Create a pricebook entry for custom pricebook
PricebookEntry pbe2 = new PricebookEntry(Pricebook2Id=pb.Id, Product2Id=prod.Id,
IsActive=true, CurrencyIsoCode='ARS', UnitPrice=100,

  UseStandardPrice=false);

insert pbe2;

test.startTest();

delete prod;

test.stopTest();

}
}

 


When I run this test class, I get this error message:

 

 Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

In the line: insert pbe2;

 

 Can someone understand why this is happening? Thanks!

I need examples for the foll:

1) How to create Sample HelloWorld WebService using Apex?.

2) How to generate WSDL for this Sample HelloWorld WebService ?. 

3) How to consume that Sample HelloWorldWebService in VisualForce page?..

 

Any Help would be appreciated.