• TrueCloud
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 48
    Replies

I need to implement the following; Based on the below criteria for case creatorID and case owner id, I want to display a message ( not a error message) stating " This case was created by a CAS agent. It will get reassigned to the case creator"). Right now my code displays an error message but the user has to go back to the case and change owner. 

 

Is there a way to display a message and change the ownerid automatically via the trigger?

 

if ((a.STATUS == 'Awaiting Internal Response'&& a.RecordTypeID == '012300000004rDZ')&&  
                     (casecreatoriwdalias =='CAS' ||casecreatoriwdalias =='TASR/P1')&&  
                       (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))     {
                         a.IWD_Testing__c = 'trigger 2 enter the loop';    
                         a.iwd_check__c    = true;                        
                                }// status
                                
            if (a.iwd_check__c){
                   err_msg = 'Case opened by TASR/P1 or CAS Agent: Please assign it to:';
                   err_msg += casecreatoriwdalias + ' ' + a.CreatedById + '<br>';
                   a.addError(err_msg);

                   a.ownerid  = caseowner;
                             } 

 

 

Thanks

Chitra

  • September 22, 2010
  • Like
  • 0

Hi all,

 

I am trying to create a trigger on a related case that would update a field on the parent case when the new related (child) case is created against the parent. I am not an expert at apex triggers but have modified some code. I have copied it below.

 

Can anybody help me complete the code for this to work.

 

Thanks

 

 

 

trigger UpdateParentCase on Case (after insert, after update){
Case relcase = Trigger.new[0];
Case ca = new Case();
for(Case c:[Select Id,  Attempted_Call__c from Case where
Id = :relcase.Parent limit 1]){
ca = c;
ca.Attempted_Call__c = true;
update ca;
}
}

I'm trying to figure out how to set a variable based on a child field.  My SOQL is part of a for loop and I need to reference the CloseDate and Committed_Premium__c fields but I don't know how.  I've searched and read all morning and can't figure this out.  Please help.

 

 

for (Account A : [Select a.Id, a.Name, a.OwnerId, a.Total_Premium__c, (Select o.CloseDate, o.Committed_Premium__c From Opportunities o where o.CloseDate > 2010-03-01) From Account a where a.type in ('Prospective Agency', 'Existing Agency')]) {

How can we extract IP Address of client, who visited our Sites. And This Site is basically developed using VF Page and Controller class. ?

I needed to have information of client machine like, IP Address /IE version/Windows-OS etc.

Please suggest How can I get such information of visitors.

Is there any API calling or what idea behind this?

Like in VB Script or any Scripting Page we can easily get Client IP Address.

  • September 24, 2010
  • Like
  • 0

The salesforce users in our organisation often forget to execute tasks they have been assigned to or they just forget to mark their tasks as completed, eventhough they did the necessary things to complete them.

 

I'd like to remind them of their overdue tasks by sending out an automatic email every week/2 weeks with an overview of all the overdue tasks assigned to them.

 

Is this possible? If yes, how can it be implemented best?

 

 

Thanks in advance.

  • September 24, 2010
  • Like
  • 0

I've got a trigger I wrote and put in our sandbox, it works great and production has all the same fields.  So now I have to build the class to test it. I thought I had it and it errors out instead.

 

The trigger is as follows and does work...

 

 

trigger OwnerLinkUpdate on Opportunity (before insert, before update ) {
 for (Opportunity a :Trigger.NEW) {
    a.Owner_Link__c = a.OwnerId;
    a.TM_Descr__c = a.Description.substring(1, 100); 
    }
}

 

trigger OwnerLinkUpdate on Opportunity (before insert, before update ) {

for (Opportunity a :Trigger.NEW) {

a.Owner_Link__c = a.OwnerId;

a.TM_Descr__c = a.Description.substring(1, 100);

}

}

 

And below is my class I currently have but know it is wrong.

 

@isTest

private class TestOwner_link {

 

    public static testMethod void OwnerLinkTest() {

     Opportunity o = [Select o.Id, o.Description FROM Opportunity o WHERE o.ID = '006Q0000005MIEK'];

o.Description = 'P123456789 - Appt Secured 9/21/2010 16:00 - Test Description to see if this will update correctly.';

        update o;

    

       Opportunity opp = new Opportunity(name = 'IS TEST 2' , StageName = 'Prospect',

        AccountId = '001Q000000EmsJs', OwnerId = '00580000001khcs',

        CloseDate = date.newinstance(2010, 10, 21), Product_Service_Type__c = 'Alarm',

        Product_Service_Detail__c = 'Burglar Alarm System', Type = 'NEW',

        Level__c = 'Recommended (We seek out the account to give them a proposal.)',

        LeadSource = 'Sales Rep Generated', Description = 'Text', External_ID__c = 'P123456789');

       insert opp;

 

    }

}

 

 

Any help would be appreciated, I have been reading posts and can't seem to find anything that seems to make the class work and the trigger cover 100%.

 

 

 

  • September 24, 2010
  • Like
  • 0

My requirement is as follow

 

I have a Visual force page with some input fields

It has a lookup field

When user click on Search icon ------Standard Search popup opened -------- User select some record

and return back to original page

when it returns to original page I want to retrive some data from selected master record and populate on the page 

Please help me how to catch this event in javascript or apex....

 

code is as follow

 

 

<apex:pageBlockSection id="GeneralInfo" columns="1" showHeader="true" title="General Information for Claims"> 
<apex:inputField Value="{!Claim__c.Name}"/>
<apex:inputField Value="{!Claim__c.Description__c}"/>
<apex:inputField Value="{!Claim__c.RequestedAmount__c}"/>
<apex:inputField Value="{!Claim__c.Fund_Request__c}"  onchange="changed()" onselect="selected()" onmouseout="mouseout()" onblur="alert('onblurred');"/>
</apex:pageBlockSection>

 

 

If we capture this event, then We can populate fields using ajax :)

 

Thanks in advance,

Bala

 

  • September 23, 2010
  • Like
  • 0

I have a custom object that we use to track our business from order through payment.  Part of that tracking includes what items are shipping, in what quantity and at what price.  I'd like to use the same functionality as our sales team uses on the opportunities - ADD PRODUCTS.  That works exactly as I need this to work, with a list of all products, the ability to select the relevant ones, enter a quantity, an extended price and track any comments as well.  I just can't seem to figure out how to get that functionality on a custom object.  

 

I considered using a different opportunity record type, but that won't work for a variety of reasons.  

 

So, is there a way to put the "Add Products" functions on a custom object?

  • September 23, 2010
  • Like
  • 0

This code logs a task based on the current disposition field, it also schedules a task based on a follow up required check box and a follow up date field. I am creating the tasks fine, but dont seem to be able to set the ActivityDate. Can some one tell me what I am doing wrong?

 

 

{!requireScript("/soap/ajax/13.0/connection.js")}

try
{
var account = new sforce.SObject("Account");
var task = new sforce.SObject("Task");
var followUp = new sforce.SObject("Task");

account.id = "{!Account.Id}";
account.IsDirty__c = true;

// set task 'assigned to' field to the current user
task.OwnerId = "{!Account.OwnerId}";
task.Subject = "{!Account.Current_Disposition__c}";
task.WhatId = "{!Account.Id}";
task.Description = "{!Account.Notes__c}";

// set status to closed
task.Priority = "Normal";
task.Status = "Completed";

// if follow up required, then create the follow up task
if ({!Account.Follow_Up_Required__c})
{
followUp.OwnerId = "{!Account.OwnerId}";
followUp.Subject = "Follow Up Call";
followUp.WhatId = "{!Account.Id}";
followUp.Description = "{!Account.Notes__c}";

// set status to closed
followUp.Priority = "Normal";
followUp.Status = "Not Started";
followUp.IsReminderSet = true;
followUp.ActivityDate = Date.valueOf({!Account.Follow_Up_Date__c});
}

var result = sforce.connection.update([account]);
var resultT = sforce.connection.create([task]);
var resultF = resultT;

if (followUp != null)
{
resultF = sforce.connection.create([followUp]);
}

if (result[0].getBoolean("success") && resultT[0].getBoolean("success") && resultF[0].getBoolean("success"))
{
account.IsDirty__c = false;
account.Follow_Up_Required__c = false;
account.Follow_Up_Date__c = null;
account.Current_Disposition__c = null;
account.Notes__c = null;

result = sforce.connection.update([account]);

if (result[0].getBoolean("success"))
{
window.location.reload();
}
}
else
{
alert("Error!");
}
}// End try block
catch(err)
{
alert("Error creating task: " + err.toString());
}

Hi All

 

I'm facing a strange issue.. Need your suggestions.

 

I have a trigger on Case which changes the recordtype when the case owner changes to a queue.

 

So i'm using below statement to get the recordtype id based on the name.

 

Schema.SObjectType.Case.getRecordTypeInfosByName().get('case record type').getRecordTypeId();

 

We have many profiles in our org , this statement is working for everyone except one profile.

 

As apex runs in system mode, i dont think recordtype access is an issue.

I tried using a query instead of above statement and it works even for this profile.

 

Recordtype temprectypeid=[Select Id from RecordType where name='case record type'];

 

I checked running the same statement in system log and getting null pointer exception where as for other profiles it works.

 

I tried comparing all the profile settings, every thing seems to be same.

 

Can any one help me debug the issue. I may be missing something.

 

Any pointers will be of great help

 

Thanks

Swapna

 

  • September 23, 2010
  • Like
  • 0

The following trigger,  and an alternative suggested on this board, do not work as planned because the IF always evaluates to FALSE, even when the account manager field is non-blank.

 

Original Failing Trigger

trigger OpportunityTrigger on Opportunity (before ​insert) {

  for(Opportunity o : Trigger.new) {
    String accountManager = (String)o.Q2_Account_M​gr__c;
    
    if((accountManager != null && accountManager.l​ength() >= 15)) {      
      o.OwnerId = o.Q2_Account_Mgr__c;  
    } } }

 

Suggested Alternative

for (Opportunity o : trigger.New) {

if (o.Q2_Account_Mgr__c != null) {

o.OwnerId = o.Q2_Account_Mgr__c;

 

Related Info

  • field Q2_Account_Mgr__c is a lookup field on the Account record that is related to a User
  • Irrespective of whether this field conatins data or is empty, the IFs in either trigger always evaluate to FALSE

Is the problem that since this trigger runs on the Opportunity that it can't see a lookup field on the Account?  Or ??

 

 

  • September 23, 2010
  • Like
  • 0

I would like to copy the email address I have in the account to a custom email field I created in the opportunity associated with that account. I need a email field in the opportunity in order to notify via email after an approval proces has been approved. If this email field doesn´t exist I can´t send an email to the account. Is there a way with appex code to automate this copying and pasting??

 

Thanks!

  • September 23, 2010
  • Like
  • 0

I need to implement the following; Based on the below criteria for case creatorID and case owner id, I want to display a message ( not a error message) stating " This case was created by a CAS agent. It will get reassigned to the case creator"). Right now my code displays an error message but the user has to go back to the case and change owner. 

 

Is there a way to display a message and change the ownerid automatically via the trigger?

 

if ((a.STATUS == 'Awaiting Internal Response'&& a.RecordTypeID == '012300000004rDZ')&&  
                     (casecreatoriwdalias =='CAS' ||casecreatoriwdalias =='TASR/P1')&&  
                       (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))     {
                         a.IWD_Testing__c = 'trigger 2 enter the loop';    
                         a.iwd_check__c    = true;                        
                                }// status
                                
            if (a.iwd_check__c){
                   err_msg = 'Case opened by TASR/P1 or CAS Agent: Please assign it to:';
                   err_msg += casecreatoriwdalias + ' ' + a.CreatedById + '<br>';
                   a.addError(err_msg);

                   a.ownerid  = caseowner;
                             } 

 

 

Thanks

Chitra

  • September 22, 2010
  • Like
  • 0

Hello.  I posted a related note a few days ago but am still running into some issues with my problem - so I was curious to see if anyone had any further suggestioins.

 

In short, I am trying to use Apex code to sum the number of customer work order records (in custom object Work_Orders__c) for each customer that are in the initial stage - and then update a specific field (WO_Total__c) in the customer object (Customer__c) with this value.  Due to how this application was developed, I am not able to accomplish this via a rollup field...so I have to use Apex.

 

The below code is not running into any syntax errors...but the WO_Total__c field in the customer object is still not being updated with any value.

 

Any thoughts would be greatly appreciated.  Thanks.

 

 

trigger CountWOStatus on Work_Orders__c (after insert) {

 

    Map <String, Integer> WOCount = new Map <String, Integer> ();

 

    id WOid = null;
    Integer nbr = null;

 

list<id> ListOfWO = new list<id>();
for (Work_Orders__c WOs: Trigger.new){
if (WOs.Customer__r.Name != null)
ListOfWO.add(WOs.Customer__r.Name);
}

 

    for (AggregateResult agr: [SELECT  Customer__r.Name, count(Id) numOfWO FROM Work_Orders__c
        WHERE Customer__r.Name in :ListOfWO
 AND (CurrWOStatus__c = 'Initial Stage')
        GROUP BY Customer__r.Name]){


       WOid = string.valueOf(agr.get(' Customer__r.Name '));
       nbr = integer.valueOf(agr.get('numOfWO'));
       WOCount.put (WOid, nbr);
       }
  

    try {
       for (Work_Orders__c IndivWOUpdate : Trigger.new){
       if (Integer.valueOf(WOCount.get(IndivWOUpdate.Id)) != null){
       IndivWOUpdate.Customer__r.WO_Total__c = Integer.valueOf(WOCount.get(IndivWOUpdate.Id));
}
       } // end for IndivWOUpdate
     }// end try

 
    catch (System.Queryexception e){
       System.debug('WOItemCount ERROR:' + e);

    } // end catch

}

Hi,

 

 

When we add tags to some object say opportunity, salesforce allows to save tags that contain comma, underscores, dashes, letters and numbers. Special symbols and characters are not allowed.

 

Now what i am trying to achieve is as follows:

 

I am trying to upload a file to workspace using content version object. While uploading the file i am also adding some tags. So even when the user enters special symbols he is allowed to save the file and the tags also appear in workspace. I want to force the user to only enter numbers, dashes, letters, underscores, comma. If he enters other values, he must get an error message.

In datatable select  campaign name  field using checkbox and and insert that particular contact name in select campaign name as a campaign member

 

 

please help....urgent