• pumbaa
  • NEWBIE
  • 25 Points
  • Member since 2012

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

Hi All,

When i click on this link it should open in new window or tab......

 

<apex:column >
<apex:outputLink value="/{!service.serviceContract.Service_Asset__c}">{!service.sodo.Products__r.Name}</apex:outputLink>
</apex:column>

 

 

Hi,

I have a great need in enabling Javascript in Service Cloud Console.

For example, I have a javascript in home page component which expand the range of the Calendar for date field. This works fine for Accounts and Contacts in regular Sales console when I enable the home page component in home page layout. However when it goes to SCC everything is in an iframe.

What I'm doing right now is in SCC Account page -> edit page layout -> click Custom Console Components

In Primary Tab Components -> Right Sidebar, I choose Type: Visualforce Page, Visualforce Page: HomePageLoader (this visualforce page is basically load the Home Page in an iframe of the VF page so javascript in Home Page component can make change to the main page. Note: this is a hack since VF page and standard SF page are using different domains)

This works most of the time but doesn't seem to be a good practise. It seems like sometimes run into a concurrency problem and javascripts (home page in the iframe) will never finish loading.

 

Here's the code for HomePageLoader VF page:

<apex:page >
<apex:includeScript value="/support/console/25.0/integration.js"/>
<script type="text/javascript">

(function () {
   setTimeout(function () {
       sforce.console.getEnclosingPrimaryTabId(function (result) {
           var subdomain = '{!URLFOR(JSENCODE($Action.Account.Tab), JSENCODE($ObjectType.Account), null, true)}';
           subdomain = subdomain.substring(0, subdomain.indexOf(".salesforce.com"));
               
           var homePageUrl = subdomain + ".salesforce.com/home/home.jsp?tabId=" + encodeURIComponent(result.id);
           setTimeout(function () { 
               var iframe = "<iframe src='" + homePageUrl + "'></iframe>";
               document.write(iframe);
           }, 50);
       });
   }); 
})();

</script>
</apex:page>
 
Here's the code for my Calendar expander Javascript&colon;
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
var startYear = 1930;
var endYear = 2050;
var optionsString = '';
if (startYear < endYear) {
for (i = startYear; i < endYear + 1; i++) {
optionsString += "<option value=\""+i+"\">" + i
+ "</option>";
}
$('#calYearPicker').html(optionsString); //change calYearPicker in regular sales console

for (j = 0; j < window.top.frames.length; j++) {
                                               //travers thru the frames in SCC and change calYearPicker in SCC
$('#calYearPicker', window.top.frames[j].document)
.html(optionsString);
}

}
});
</script>


Any advise or workaround will be great.

Thanks in advance,
Ricky

  • September 13, 2013
  • Like
  • 0

I have built a custom report using Visual Force. I am trying to give the end user the ability to sort the report by a few different fields. I have created a pick list on a Custom Object that contains the field names (API Names) that the user can sort by. In my class I query the Custom object to get the field the end user wants to sort by, I store that in a variable. I then want to use that vairble to order by my SOQL statement that builds the report.

 

Here is my codes:

 

//Set the variable from the custom field

List<Custom__c> SortBy = [Select SortBy__C from Custom__c Where Name = 'FreightDashboard' ];

 

//My Query to build the report:

SELECT Estimated_Ship_Date__c, Date_Shipped__c, Opportunity.CloseDate, Opportunity.Account.Name, From OpportunityLineItem WHERE Opportunity.StageName = 'Closed Won' and (NOT ShippingType__c like '%Small Parcel%') ORDER BY :SortBY]

 

I want my end user to be able to sort by Estimated_Ship_Date__c or  Date_Shipped__c or Opportunity.CloseDate at their choosing.

 

Any help?

Hi All,

When i click on this link it should open in new window or tab......

 

<apex:column >
<apex:outputLink value="/{!service.serviceContract.Service_Asset__c}">{!service.sodo.Products__r.Name}</apex:outputLink>
</apex:column>

 

 

Hi,

 

  I am new to salesforce, can any body help me  out,this is the sample program,please help me out how to

execute below programme.

 

 

public class newaccount
{
Integer num=10;
public void testmethod testcontroller()
{
NewAccount_c[] accs;
accs = [SELECT Id FROM NewAccount__c WHERE name LIKE 'v%'];
Delete accs;
}
}
private class testclass
{
newaccount accs= new newaccount();
accs.testcontroller();
}

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.

HI,

Please any one, help me to solve this issue

 

"System.LimitException: Too many script statements: 200001  'Extarnal entry point" in test class

this error is occure when im going to run the test class

 

Controller:

public class paymentinvoicepdf
{
public paymentinvoicepdf(ApexPages.StandardController controller)
{
}
Public List<UOP_Aggregation_Group__c> agroup{get;set;}
public String contname{get;set;}
public String title{get;set;}
public String Email{get;set;}
public String Telephone{get;set;}
public Boolean flag{get;set;} //{get;set;}
public Royalty_Contacts__c rc{get;set;}
public List<Royalty_Contacts__c> rc1{get;set;}
public List<Royalty_Contacts__c> rc2{get;set;}

public PageReference royalcon()
{
Id id=Apexpages.currentpage().getparameters().get('id');
UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c where id=:id];
id urpid=urp.Process_Unit__c;
 rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 if(rc1.size()>0)
 {
 flag=true;
 }
 
 rc2=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Secondary)' and Royalty_Role__c=:'Royalty (Primary)' ];
 if(rc2.size()>0)
 {
 flag=false;
 }
 /*for(Royalty_Contacts__c r:rc1)
 {
 if(r.Royalty_Role__c=='Royalty (Primary)')
 {
 flag=true;
 contname=r.Contact__r.name;
 title=r.Title__c;
 Email=r.Email__c;
 Telephone=r.Phone__c;
 //rc=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 }
 else if(r.Royalty_Role__c=='Royalty (Secondary)')
 {
 flag=false;
 }
 
 }*/



 Process_Unit__c pu=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:urpid];
 id aid=pu.Aggregation_Group__c;
 
 agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:aid];
 
return null;
}

}

 

test class:

@istest()
public class paymentinvoicepdftest
{
public static testmethod void test()
{
UOP_Royalty_Payment_History__c uopCreat=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report');
ApexPages.StandardController accCtrl = new ApexPages.Standardcontroller(uopCreat);


paymentinvoicepdf pay=new paymentinvoicepdf(accCtrl );
Account ac=new Account(name='test');
//ac.SAP_Customer_Info__c=s.id;
insert ac;
Process_Unit__c pu=new Process_Unit__c(name='testAccount',Account__c=ac.id,Status__c='Licensed',Technology_Supplier__c='ABB Lummus',
Units_Fully_Paid_Capacity__c='Accounting Units',Agreement_Status__c='Fully Executed',License_Type__c='Unit',Subject_To_Audit__c='yes',
Current_Royalty_Type__c='Fully Paid',UOM_Capacity__c='BPSD');
insert pu;
UOP_Royalty_Payment_History__c uop=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report',Process_Unit__c=pu.id,
Royalty_Rate__c=0.50,Applicable_BLS__c=10,BLS_Base__c=100,UOP_Year__c='2001',Overage__c=11000);
insert uop;
    ApexPages.currentPage().getParameters().put('id',uop.id);

UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c limit 1];
List<Royalty_Contacts__c> rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urp.id and Royalty_Role__c=:'Royalty (Primary)']; 
 Process_Unit__c pu1=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:pu.id limit 1];
 UOP_Aggregation_Group__c a=new UOP_Aggregation_Group__c(name='test');
 insert a;
 
 List<UOP_Aggregation_Group__c> agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:a.id];
 
pay.royalcon();
}
}

 Give me some suggestions how to solve this issue

 

Thanks,

Vishwa A

I have an apex trigger that runs when a Chatter message is posted. I also have a custom object.  I would like to write text to the custom object from my apex trigger.  Everything works fine when an admin user posts a chatter.  However, when a non admin user posts a chatter I get an exception:

 

 

Apex trigger company.test caused an unexpected exception, contact your administrator: company.test: execution of BeforeUpdate

caused by: System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []: (company)

 

 

 

How do I get this to work for non admin users?

 

Hello...

 

Im having one problem trying to convert values to show on my visualforce page:

 

How can i convert the following number to have to decimal places...

 

Sometimes i ll have a number like. 42.0 other time i ll have a number like 37.3333333333333

 

Im trying to solve it using what i found here. but the problem is always the same.

 

Tks for everything