• Yam Admin
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
We have several Workflow Rules that create Workflow Tasks x days later than the Rule trigger date.  We would like to create an Apex Trigger that will automatically calculate the day of the week the new Task is due on and if on a weekend, change the date to 2 day later.

I know it's possible to calculate Day of Week in a formula field thanks to this blog post.

I've already read the Apex Language Reference and created some simple Apex Triggers, but I just don't have enough experience working with Apex Triggers to know how to do this.  Any help or samples would be greatly appreciated.

Thanks,

Matt
I'm trying to update the "recalcQuoteAmount.htm" s-control in the "Sales Quote with Product Line Items" app on the Appexchange to work with API 8.0, but I keep getting the following error:
Line: 1084
Char: 13
Error: Exception thrown and not caught
Code: 0

Here is my updated version of the s-control:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/8.0/connection.js"></script>
<script type="text/javascript">
<!--
// just run a total
function jumpbackQuote() { jumpback("/{!SFDC_520_Quote_ID}") }
function initPage() {
setTimeout("setup()",300);
}
var quoteLineTotal = 0;
function totalQuote(q) { quoteLineTotal += q.get("Ext_Net_Price__c"); }
function setup() {
var QuoteLineQ = sforce.connection.query(
"select Ext_Net_Price__c from SFDC_520_QuoteLine__c where Quote__c = '{!SFDC_520_Quote_ID}'");
if ( QuoteLineQ.className != 'QueryResult') {
alert ( "Query failed for quote lines") ;
if (QuoteLineQ.className == 'Fault' ) alert('fault: '+QuoteLineQ.toString());
jumpbackQuote();
}
if ( QuoteLineQ.size < 1 ) {alert("No Line Items in this Quote ?");jumpbackQuote();}

QuoteLineQ.records.map(totalQuote); // alert("total is "+quoteLineTotal);

// write Quote_Amount__c
var upd = new sforce.SObject("SFDC_520_Quote__c");
upd.set("Id","{!SFDC_520_Quote_ID}");
upd.set("Quote_Amount__c",quoteLineTotal);
var result = sforce.connection.create([upd]);

jumpbackQuote() ;
}

// util functions
function jumpback(retUrl) {
window.opener.location.href = retUrl;
window.close();
//window.parent.parent.location.href = retUrl; // works when in a frame of sfdc
}
Array.prototype.map = function(func) { // function called on each element of the array
var ret = [];
for(var x=0;x<this.length;x++) {
func(this[x]);
ret.push(this[x]); // return the entire list
}
return ret.length>0?ret:null;
}
</script>
<body onload="javascript:initPage();" >
<center>
<p><h3>Please wait, updating quote amount : {!SFDC_520_Quote_Name}</h3>
<br>
<img src="/img/waiting_dots.gif" border="0" width=156 height=25>
</center>
</body>
</html>

Any help would be greatly appreciated
I'm trying to update the "recalcQuoteAmount.htm" s-control in the "Sales Quote with Product Line Items" app on the Appexchange to work with API 8.0, but I keep getting the following error:
Line: 1084
Char: 13
Error: Exception thrown and not caught
Code: 0

Here is my updated version of the s-control:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/8.0/connection.js"></script>
<script type="text/javascript">
<!--
// just run a total
function jumpbackQuote() { jumpback("/{!SFDC_520_Quote_ID}") }
function initPage() {
setTimeout("setup()",300);
}
var quoteLineTotal = 0;
function totalQuote(q) { quoteLineTotal += q.get("Ext_Net_Price__c"); }
function setup() {
var QuoteLineQ = sforce.connection.query(
"select Ext_Net_Price__c from SFDC_520_QuoteLine__c where Quote__c = '{!SFDC_520_Quote_ID}'");
if ( QuoteLineQ.className != 'QueryResult') {
alert ( "Query failed for quote lines") ;
if (QuoteLineQ.className == 'Fault' ) alert('fault: '+QuoteLineQ.toString());
jumpbackQuote();
}
if ( QuoteLineQ.size < 1 ) {alert("No Line Items in this Quote ?");jumpbackQuote();}

QuoteLineQ.records.map(totalQuote); // alert("total is "+quoteLineTotal);

// write Quote_Amount__c
var upd = new sforce.SObject("SFDC_520_Quote__c");
upd.set("Id","{!SFDC_520_Quote_ID}");
upd.set("Quote_Amount__c",quoteLineTotal);
var result = sforce.connection.create([upd]);

jumpbackQuote() ;
}

// util functions
function jumpback(retUrl) {
window.opener.location.href = retUrl;
window.close();
//window.parent.parent.location.href = retUrl; // works when in a frame of sfdc
}
Array.prototype.map = function(func) { // function called on each element of the array
var ret = [];
for(var x=0;x<this.length;x++) {
func(this[x]);
ret.push(this[x]); // return the entire list
}
return ret.length>0?ret:null;
}
</script>
<body onload="javascript:initPage();" >
<center>
<p><h3>Please wait, updating quote amount : {!SFDC_520_Quote_Name}</h3>
<br>
<img src="/img/waiting_dots.gif" border="0" width=156 height=25>
</center>
</body>
</html>

Any help would be greatly appreciated