• Jayse
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi All,

 

I have a requirement to have a pop up window appear when a user attempts to close a tab on the service console, in this instance without updating a case.

 

I am struggling to find a way to consistiently catch whether the user has closed a tab on the console. I have tried using the 

sforce.console.onFocusedPrimaryTab() method, but a) it doesn't consistienly fire (ie. when there is only 1 tab and the dashboard on the console); and b) the javascript I have tried adding to see whether a tab has actually been closed when the focus of the console changes doesn't work either (with some strange behaviour of basic javascript functions (String.split) not working full stop).

 

Is there a standard method to capture this (I have seen this question previously asked, but with no answer).

 

or

 

Has someone managed to implement this, in which case some guidance would be much appreciated. *

 

* this is based on taking my current approach to determine what tabs are on the console when the primary tab focus changes. is there an easy way to distingush that a user has selected a different tab or opened a new one rather than closing one down (at which point i'd need to invoke my business logic).

 

Many thanks in advance.

  • July 02, 2013
  • Like
  • 0

Hi Everyone.

 

I've seen a few posts that are similar, but not the same as what i'm encountering. I've written a bulkified trigger (or at least i think I have), but when I load data in with dataloader, it does not appear that the trigger has fired when i open up the record.

 

If i click edit and save on the record, I can see the trigger has worked as it populates the fields as I expect it to. 

 

trigger code is below: 

 

trigger salesDataSellToCustomerTrigger on Sales_Data__c (before insert, before update) {

   Map<String, Sales_Data__c > salesDataMap = new Map<String, Sales_Data__c >();
   
   for (Sales_Data__c salesData: System.Trigger.new) { 
       
       if (salesData.Sell_to_Customer_No__c == null ) {
           salesData.Sell_to_Customer_Id__c = null;
       }
       else {
           salesDataMap.put(salesData.Sell_to_Customer_No__c, salesData);
       }
   }
    
   // Using a single database query, find all the accounts in 
   // the database that have the same Company No as any 
   // of the Sales Data with SellToCustomer Number
    
   for (Account account: [SELECT Id, Company_No__c FROM Account
                     WHERE Company_No__c IN :salesDataMap.KeySet()]) {
       Sales_Data__c sData = salesDataMap.get(account.Company_No__c);
       
       // update SalesData SellToCustomer ID
       sData.Sell_to_Customer_ID__c = account.id;
   }
}

Thought there may be an option in the data loader settings, but I couldn't see anything obvious, so any advice / guidence would be appreciated.

 

Jayson

  • August 16, 2012
  • Like
  • 0

Posted this in the Apex dev board, but thinking someone on here may be able to assist.

 

Link

 

Thanks

  • July 04, 2012
  • Like
  • 0

I have a simple formula field, below, which evaluates correctly when viewing it in the page layout.

 

if (User__r.Profile.Name = 'System Administrator', 'FIXED TRUE', User__r.Profile.Name)

 

The problem I have is when I try and lookup / reference the field in SOQL, i get a different result to what i see in the page layout, SOQL below:

 

select name, isActive__c from Incentive_Plan__c where user__c =:UserId

 

For the simple formula field logic above, the SOQL query returns the value 'PT1 ', I have no idea where it is getting this value from !

 

Hope someone can explain this behaviour.

 

Thanks

  • July 04, 2012
  • Like
  • 1

Hi,

 

I have a simply query in my apex class to return a record from a custom object, code below:

 

userIncentivePlan = [select name, isActive__c, owner.name, Target__c, Growth_Incentive_Rate__c from Incentive_Plan__c where user__c =:UserId and isActive__c='True'];

 With the "isActive__c = 'True'" where criteria, the query fails to return any results, therefore I am assuming it  always evaluates to false. (also confirmed this by printing it out to a visual force page)

 

the formula on the field contains some nested if statements but always equates to 'True' or 'False', code below:

 

if (User__r.Profile.Name = 'System Administrator',  Incentive_Rate__r.isActive__c , 
if (User__r.Profile.Name = 'Corporate Sales Manager', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Developer', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Manager', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Sales Super User', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Account Development Manager', 
  if ( AND ( Incentive_Rate__r.isActive__c ='True',  Growth_Incentive_Rate__r.isActive__c ='True'), 'True', 'False'), 'False')
))))) 

The isActive__c field reference on the incentiveRate object is also a formula field [could that be the cause of the problem??]

 

Strangely, when I view the custom object record through salesforce, it evaluates correctly to 'True'

 

Having seen this forum posing, it suggests what I have done is correct : link

.... however it is not working. 

 

Any suggestions on how I can go about trying to resolve this would be appreciated.

 

Thanks in advance.

  • June 27, 2012
  • Like
  • 0

Hi everyone,

 

I'm creating an incentive calculator and am struggling with how to do the following:

 

Each sales person will have an incentive plan, which I have created as a custom object. I want a field on the object that provides a running total of what business they've done, so that I can then perform the incentive calculations.

To do this I need a sum of all the business done on that accounts, I have a custom field on account that will provide the figure for each account.

 

Is there a way to loop through all the accounts owned by the user and return a sum of the custom field that i've created on account?

 

I was looking to do this as a formula field, but I couldn't see a way to query all accounts where the owner is the same user, before looping through the results and summing the custom field that I'd created.

 

I'm starting to think this is beyond the capability of a formula field, so if there is another way I should be doing this, I'd be greatful if someone could enlighten me.

 

Thanks in advance

 

Jayson

  • June 01, 2012
  • Like
  • 0

Hi.

 

I have a strange issue as the code appears so simple, I can't understand why it's failing..

 

I have a trigger that is set to fire when a record is updated. Depending on certain criteria, it will create an event.

This event needs to be assigned to a different user. When I try setting the ownerID on creating the event, I get the following error:

 

Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]

 

If I remove the line in the insert that sets the ownerId, it successfully creates the event, but it is assigned to the wrong user.

 

Data structure is as follows:

 

custom object "Schedule" contains a lookup to another custom object "Trainer", which in turn has a look up to the "User" object.

 

Code snipit that creates the event is below.

 

trigger addEvent on Trainer_Schedule__c (after update) {

  .....  

      // if New Trainer schedule is not 'Available' and dates are not null, create event
        if (!tsNew.Trainer_Status__c.startsWith('Avail')
            && (tsNew.Depart_From_Home__c != null  && tsNew.Arrive_Back_Home__c != null )
        ) {
    //      ***** CREATE  EVENT
           
            addEvents.add( new Event( WhatId = tsNew.Product__c,
                           OwnerId = tsNew.Trainer__r.User__c,
                           Subject = tsNew.Name,
                           StartDateTime = tsNew.Depart_From_Home__c,
                           EndDateTime = tsNew.Arrive_Back_Home__c,
                           Trainer_Schedule_Id__c = tsNew.Id,
                           Trainer_Absence_Id__c = null
                         )  
            );
  ......
 
  insert addEvents;
}

 

 

Any help that anyone can give would be much appreciated.

 

Thanks

 

Jayson

 

  • May 25, 2012
  • Like
  • 0

Hi All,

 

I have a trigger that creates / updates / deletes calendar events depending on the field values on a custom object. The field it references is a formula look up on another field in the same object, which in turn is a formula field look up on a field in another custom object.

 

What I'd like is the formula fields to cascade the changes, which it does, but the trigger does not fire to update the calendar events.

 

Hope someone can help and that it's something simple i've missed / overlooked.

 

Thanks in advance.

 

 

  • March 20, 2012
  • Like
  • 0

I have a simple formula field, below, which evaluates correctly when viewing it in the page layout.

 

if (User__r.Profile.Name = 'System Administrator', 'FIXED TRUE', User__r.Profile.Name)

 

The problem I have is when I try and lookup / reference the field in SOQL, i get a different result to what i see in the page layout, SOQL below:

 

select name, isActive__c from Incentive_Plan__c where user__c =:UserId

 

For the simple formula field logic above, the SOQL query returns the value 'PT1 ', I have no idea where it is getting this value from !

 

Hope someone can explain this behaviour.

 

Thanks

  • July 04, 2012
  • Like
  • 1

Hi everyone,

 

I have an inline VFPage in which I detect page closing or page refresh or whenever the user leaves the page using the <body onunload="jsFunction()">. When it happens, I call some Apex code using Javascript remote action.

 

It works perfectly in the "standard" view of a page. But when I am using the console, I can't launch the Apex remote code.

 

I made some investigation on that. Apparently, the js code is running because I can console.log() some variables, but the call of MyExtension.myMethod doesn't work.

 

The js code :

 

var var1 = 'value1';
var var2 = 'value2';

console.log(var1);
console.log(var2); MyExtension.myMethod(var1, var2, function(result, event) { if(event.status) { console.log("Update successful"); } else { console.log("Update unsuccessful"); } }, {escape:true});

cosole.log('test');

 

The Apex code :

global with sharing class MyExtension {
	@RemoteAction
	global static void myMethod(String var1, String var2) {
		// my logic
	}
}

 

Even the console.log('test') works, but the console.log('Update successful') or console.log(Update unsuccessful') does not appear... Plus, I don't get any Debug log about that remoting.

 

There is no need to see my logic because like I said it works perfectly in standard.

 

Is there any other ways to detect cosole tab or subtab closing and call some Apex logic ?

 

Thank you !

Hi Everyone.

 

I've seen a few posts that are similar, but not the same as what i'm encountering. I've written a bulkified trigger (or at least i think I have), but when I load data in with dataloader, it does not appear that the trigger has fired when i open up the record.

 

If i click edit and save on the record, I can see the trigger has worked as it populates the fields as I expect it to. 

 

trigger code is below: 

 

trigger salesDataSellToCustomerTrigger on Sales_Data__c (before insert, before update) {

   Map<String, Sales_Data__c > salesDataMap = new Map<String, Sales_Data__c >();
   
   for (Sales_Data__c salesData: System.Trigger.new) { 
       
       if (salesData.Sell_to_Customer_No__c == null ) {
           salesData.Sell_to_Customer_Id__c = null;
       }
       else {
           salesDataMap.put(salesData.Sell_to_Customer_No__c, salesData);
       }
   }
    
   // Using a single database query, find all the accounts in 
   // the database that have the same Company No as any 
   // of the Sales Data with SellToCustomer Number
    
   for (Account account: [SELECT Id, Company_No__c FROM Account
                     WHERE Company_No__c IN :salesDataMap.KeySet()]) {
       Sales_Data__c sData = salesDataMap.get(account.Company_No__c);
       
       // update SalesData SellToCustomer ID
       sData.Sell_to_Customer_ID__c = account.id;
   }
}

Thought there may be an option in the data loader settings, but I couldn't see anything obvious, so any advice / guidence would be appreciated.

 

Jayson

  • August 16, 2012
  • Like
  • 0

I have a simple formula field, below, which evaluates correctly when viewing it in the page layout.

 

if (User__r.Profile.Name = 'System Administrator', 'FIXED TRUE', User__r.Profile.Name)

 

The problem I have is when I try and lookup / reference the field in SOQL, i get a different result to what i see in the page layout, SOQL below:

 

select name, isActive__c from Incentive_Plan__c where user__c =:UserId

 

For the simple formula field logic above, the SOQL query returns the value 'PT1 ', I have no idea where it is getting this value from !

 

Hope someone can explain this behaviour.

 

Thanks

  • July 04, 2012
  • Like
  • 1

Hi,

 

I have a simply query in my apex class to return a record from a custom object, code below:

 

userIncentivePlan = [select name, isActive__c, owner.name, Target__c, Growth_Incentive_Rate__c from Incentive_Plan__c where user__c =:UserId and isActive__c='True'];

 With the "isActive__c = 'True'" where criteria, the query fails to return any results, therefore I am assuming it  always evaluates to false. (also confirmed this by printing it out to a visual force page)

 

the formula on the field contains some nested if statements but always equates to 'True' or 'False', code below:

 

if (User__r.Profile.Name = 'System Administrator',  Incentive_Rate__r.isActive__c , 
if (User__r.Profile.Name = 'Corporate Sales Manager', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Developer', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Manager', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Sales Super User', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Account Development Manager', 
  if ( AND ( Incentive_Rate__r.isActive__c ='True',  Growth_Incentive_Rate__r.isActive__c ='True'), 'True', 'False'), 'False')
))))) 

The isActive__c field reference on the incentiveRate object is also a formula field [could that be the cause of the problem??]

 

Strangely, when I view the custom object record through salesforce, it evaluates correctly to 'True'

 

Having seen this forum posing, it suggests what I have done is correct : link

.... however it is not working. 

 

Any suggestions on how I can go about trying to resolve this would be appreciated.

 

Thanks in advance.

  • June 27, 2012
  • Like
  • 0

Hi everyone,

 

I'm creating an incentive calculator and am struggling with how to do the following:

 

Each sales person will have an incentive plan, which I have created as a custom object. I want a field on the object that provides a running total of what business they've done, so that I can then perform the incentive calculations.

To do this I need a sum of all the business done on that accounts, I have a custom field on account that will provide the figure for each account.

 

Is there a way to loop through all the accounts owned by the user and return a sum of the custom field that i've created on account?

 

I was looking to do this as a formula field, but I couldn't see a way to query all accounts where the owner is the same user, before looping through the results and summing the custom field that I'd created.

 

I'm starting to think this is beyond the capability of a formula field, so if there is another way I should be doing this, I'd be greatful if someone could enlighten me.

 

Thanks in advance

 

Jayson

  • June 01, 2012
  • Like
  • 0

Hi.

 

I have a strange issue as the code appears so simple, I can't understand why it's failing..

 

I have a trigger that is set to fire when a record is updated. Depending on certain criteria, it will create an event.

This event needs to be assigned to a different user. When I try setting the ownerID on creating the event, I get the following error:

 

Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]

 

If I remove the line in the insert that sets the ownerId, it successfully creates the event, but it is assigned to the wrong user.

 

Data structure is as follows:

 

custom object "Schedule" contains a lookup to another custom object "Trainer", which in turn has a look up to the "User" object.

 

Code snipit that creates the event is below.

 

trigger addEvent on Trainer_Schedule__c (after update) {

  .....  

      // if New Trainer schedule is not 'Available' and dates are not null, create event
        if (!tsNew.Trainer_Status__c.startsWith('Avail')
            && (tsNew.Depart_From_Home__c != null  && tsNew.Arrive_Back_Home__c != null )
        ) {
    //      ***** CREATE  EVENT
           
            addEvents.add( new Event( WhatId = tsNew.Product__c,
                           OwnerId = tsNew.Trainer__r.User__c,
                           Subject = tsNew.Name,
                           StartDateTime = tsNew.Depart_From_Home__c,
                           EndDateTime = tsNew.Arrive_Back_Home__c,
                           Trainer_Schedule_Id__c = tsNew.Id,
                           Trainer_Absence_Id__c = null
                         )  
            );
  ......
 
  insert addEvents;
}

 

 

Any help that anyone can give would be much appreciated.

 

Thanks

 

Jayson

 

  • May 25, 2012
  • Like
  • 0

Hi All,

 

I have a trigger that creates / updates / deletes calendar events depending on the field values on a custom object. The field it references is a formula look up on another field in the same object, which in turn is a formula field look up on a field in another custom object.

 

What I'd like is the formula fields to cascade the changes, which it does, but the trigger does not fire to update the calendar events.

 

Hope someone can help and that it's something simple i've missed / overlooked.

 

Thanks in advance.

 

 

  • March 20, 2012
  • Like
  • 0