• cml
  • NEWBIE
  • 50 Points
  • Member since 2010

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

I want to write a one time script to populate a new field on old records.

Since this is a new field it will get populated going further, however i don't want the field blank for old records hence this ine time script.

 

can someone please correct my code? 


//get all records that has value in startDate and endDate but no value in numberofdays

List<Custom_Object_c> sec = [SELECT Id,startDate,endDate,numberofdays from Custom_Object_c WHERE startDate !=null && endDate !=null && numberofdays==null)

//Loop through the list and update the numberofdays field

for (Custom_Object_c s: sec){

    datetime t = sec.startDate;
    date d = Date.newInstance(t.year(),t.month(),t.day());
    datetime tt = sec.endDate;
    date dd = Date.newInstance(t.year(),t.month(),t.day());
    
    integer sec.numberofdays = startDate.daysBetween(endDate);
    
    update sec;
            
}
    
}   

 

 

  • June 20, 2012
  • Like
  • 0

Hello all,

 

Having received invaluable help on this forum to help me finish off my test units, I am now trying to deploy the trigger I've been working on for the opportunity object.

 

PROBLEM #1

Trouble is, in the organization I work for, a entity with multiple companies, there are already 2 existing opportunities' triggers, that were deployed before I took over the admin role (and people left the company…).

 

So, how do I go around this ?

 

- should my test class cover testing for other triggers as well ? But then, shouldn't other triggers' test classes cover my trigger's code as well? So in fact, would I have to deploy them again ?…

 

- should I include, in my trigger, the code from already existing triggers ? And then delete other triggers before deploying mine ?…

 

PROBLEM #2

Also, to make things even more fun, there is a test class for a trigger that is not working properly (anymore?)… I tried to validate my own trigger, to see what was happening, and it fails with the following error message :

 

API NameTypeLineColumnProblem

TESTprojectNUmberBUonOpportunity.myUnitTest()Class2021Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.ProjectNumberBUonOpportunity: line 202, column 1"

 

Of course, I can't edit this trigger in production…

Hi I am writing a trigger on FeedItem which updates chatter post and add @mention. Now the issue is when we add @mention from Chatter UI, it comes as a hyperlink to User but when i do it through trigger code it doesn't come as hyperlink. I also tried to change feed type to 'LinkPost' but by that way we can only provide only one link to the post which is not the case here. Here i have to add more than one @mentions.
Is there any option by which i can achieve that? 

 

Thanks

  • June 24, 2011
  • Like
  • 0

Hi ,

 

I need to build a new CTI adapter for salesforce to integrate it with avaya. I want to do it in java.  Currently CTI toolkit provide by Salesforce is in C++, in which i am not comfortable. Can I use java to build the adapter? If yes which Salesforce API reference i need to use? Can anyone tell me from where i need to start?

 

Thanks

Regards

Chandra

  • June 17, 2011
  • Like
  • 0

Hi All,

 

I have to capture insert event when User creates a new SObject and after capturing event i have to write a code to insert a corresponding audit record to an existing audit object. I cann't do it with trigger because it works only when a new record inserted/updated for an existing SObject.

 

Please help me on this.

 

Or can we have something by which we could able to identify existing Salesforce SObjects in Apex code ?

  • March 02, 2011
  • Like
  • 0

Currently we have our own lead conversion logic because of that we are not able to stamp some of the fields which get stamped with out of the box lead conversion logic for ex: IsConverted, ConvertedAccountId, ConvertedContactId, ConvertedDate, ConvertedOpportunityId are the standard OOTB fields and getting stamped with OOTB lead conversion logic but we are not able to stamp those fields in our custom lead conversion logic.
Is there any way to stamp those fields in our custom lead conversion logic?

  • December 27, 2011
  • Like
  • 0

I am attempting to basically replicate the product object and functionality for a custom object I created called 'Inventory' on the opportunity records. I have created a button called 'add inventory' to the inventory custom object on the opportunity but I am not great with APEX or Java and I need the button to bring up a multi-select list of all of the 'inventory equipment' which have been uploaded as records on another custom object called 'inventory equipment'. It is literally exactly what the add product button does but I need it to bring up all of the inventory equipment records and relate them to the opportunity.

 

Can anyone help on this??

I want to write a one time script to populate a new field on old records.

Since this is a new field it will get populated going further, however i don't want the field blank for old records hence this ine time script.

 

can someone please correct my code? 


//get all records that has value in startDate and endDate but no value in numberofdays

List<Custom_Object_c> sec = [SELECT Id,startDate,endDate,numberofdays from Custom_Object_c WHERE startDate !=null && endDate !=null && numberofdays==null)

//Loop through the list and update the numberofdays field

for (Custom_Object_c s: sec){

    datetime t = sec.startDate;
    date d = Date.newInstance(t.year(),t.month(),t.day());
    datetime tt = sec.endDate;
    date dd = Date.newInstance(t.year(),t.month(),t.day());
    
    integer sec.numberofdays = startDate.daysBetween(endDate);
    
    update sec;
            
}
    
}   

 

 

  • June 20, 2012
  • Like
  • 0

I have field in account named pick (picklist field) and I want to populate that field automatically in contact , a field name called accountpickvalues

Hi guys,

 

I am new to salesforce .i am facing a problem can any body help me out.

 

Problem:-

 

I had a lookup filed called broker onto( contact) in opportunity.

And another lookup filed in a custom object (loan)with the same name broker on to (contact).

my requirement is if i update the  broker in loan it should update the opportunity broker field.

if i update with latest value in opportunity broker then it should update the same value in loan object broker filed.

 

please help me in these in writing the trigger.

 

Thanks in Advance.

How to get the custom object custom field values using vlookup.
Here is my requirement.
Assume 2 custom objects namely QTPStatus and QTPPosition
QTPPosition object has Position Name as custom field. When QTPPosition object is created, a standard field named 'QTPPositionName' created automatically.

Now i will create field with vlookup datatype on QTPStatus object relating to 'QTPPosition' object to fetch the values of the field 'Position Name'.
In visual force page can u help me how to get the values of the field 'Position Name' from QTPPosition object.
I am getting the values of standard field 'QTPPositionName' that is created on 'QTPPosition' object.

 

Can someone help me on this requirement.

if the user with some profile creates some notes and attachments in contact , it should be visible only to users who are having the same profile. it should not be visible to the other profile users. how to achieve that?

Hi 

  When i log in as portal user asn click on a record i am getting this information

 

Insufficient Privileges

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 

 

Can anybody help me how to salove this problem.

 

Thanks

Anu

Hello all,

 

Having received invaluable help on this forum to help me finish off my test units, I am now trying to deploy the trigger I've been working on for the opportunity object.

 

PROBLEM #1

Trouble is, in the organization I work for, a entity with multiple companies, there are already 2 existing opportunities' triggers, that were deployed before I took over the admin role (and people left the company…).

 

So, how do I go around this ?

 

- should my test class cover testing for other triggers as well ? But then, shouldn't other triggers' test classes cover my trigger's code as well? So in fact, would I have to deploy them again ?…

 

- should I include, in my trigger, the code from already existing triggers ? And then delete other triggers before deploying mine ?…

 

PROBLEM #2

Also, to make things even more fun, there is a test class for a trigger that is not working properly (anymore?)… I tried to validate my own trigger, to see what was happening, and it fails with the following error message :

 

API NameTypeLineColumnProblem

TESTprojectNUmberBUonOpportunity.myUnitTest()Class2021Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.ProjectNumberBUonOpportunity: line 202, column 1"

 

Of course, I can't edit this trigger in production…

Hello,

 

The scenario is something like whenever a user "Jr. Executive" tries to delete a record of an object ,it cannot be deleted unless this action is approved by the "Manager" above in the hierarchy. I have tried this by the help  of  a dummy status field but was unable to execute it succesfully.

 

Please help me out!!

 

Regards

 

Asit Mishra

  • June 18, 2012
  • Like
  • 0

trigger changestatus on Selected__c (before insert,before update) {
for(Selected__c sc:trigger.new) {
list<Selected__c> s = new list<Selected__c>([select id,Hours__c from Selected__c where availability__c = :sc.availability__c]);
Availability__c a = [select Hours__c,update_field__c from Availability__c where id=:sc.availability__c ][0];

if(sc.Hours__c <= a.update_field__c )
{
a.update_field__c = a.update_field__c - sc.Hours__c ;
system.debug(a.update_field__c+' ********************');
update a ;

}

}

}

Doing some sandbox development. We are attempting to redirect a button to a new visualforce page and the page we have is not listed in the Override Properties. Here is our code for the VF page which works when manually triggered using this link https://cs14.salesforce.com/apex/newbuttonredirect

 

<apex:page standardController="Account" extensions="newbuttonredirect"

action="{!pageredir}">

</apex:page>

 

And then the Apex Class

 

public class newbuttonredirect

{

 

public newbuttonredirect(ApexPages.StandardController controller)

{

 

}

public Pagereference pageredir()

{

    Pagereference newpage = new Pagereference ('/500/e?cas16=Name:%0AAddress:%0APrimary Contact:%0ASecondary Contact:%0ADSLUsername:%0ADSL Password:%0ADSL Phone Number:%0ACABLE Modem MAC:%0AEMTA MAC:%0AShentel Phone Number:%0ASTB Serial number:%0AAvailability:%0AContact Customer Prior to Visit:%0ATicket Notes:%0AAware of Charges:%0ADirections:&retURL=/500/');

    return newpage;

}

}

 

 

I understand this might not be the best route any suggestions

 

We have a custom object that has role based access.

 

There are 3 roles with access to a layout of this object.

 

There is a button on this page "Update" that takes everyone regardless of role to an VF input page (lots of rows and columns)

 

Now we want this"Update"  button to take the user to an input page that is based on their Role (Role 1, Gets Set 1 of columns; Role 2, Set 2; Role 3, Set 3).

 

Is it possible/easiest to overload the button to make this decision or just create a traffic cop VF page that makes the decion and sends the User to the appropriate page?

 

Or is there some other way I have not thought of.

 

thanks,

 

lee

New to visual force and haven't used HTML in years so i'm having a hard time figuriring out how to make this look good.

 

Essentially i am creating a table of dynamic report links to be placed on a users homepage.  In order to leverage the ?pv0={!$User.Id} parameter in an HTML area within the home page i have to first use a visual force page to encode the links then represent this VF page using an iframe in the HTML hompage component.  Got that working so now the reports receive the current User.Id parameter but am struggling to modify the appearance.

 

here is the VF code i have managed to kludge together.

 

<apex:page standardStylesheets="true" showheader="false" sidebar="false" >
<apex:outputText >Welcome to Salesforce</apex:outputText><br></br>
<apex:outputtext >Below you will find all the information you require</apex:outputtext>

<apex:panelGrid id="theGrid" columns="2" border="4" cellpadding="4" cellspacing="6" style="Theme3">
<apex:outputLink value="/00OJ0000000FGuz?pv0={!$User.Id}" target="_blank" style="Theme1" id="theLink">My Awesome Custom Report</apex:outputLink>
<apex:outputLink value="/00OJ0000000FGuz?pv0={!$User.Id}" target="_blank" id="theLink2">My Awesome Custom Report 2</apex:outputLink>
<apex:outputLink value="/00OJ0000000FGuz?pv0={!$User.Id}" target="_blank" id="theLink3">My Awesome Custom Report 3</apex:outputLink>
<apex:outputLink value="/00OJ0000000FGuz?pv0={!$User.Id}" target="_blank" id="theLink4">My Awesome Custom Report 4</apex:outputLink>
</apex:panelGrid>
</apex:page>

 

The HTML Area home page compoenent is this:

 

<iframe src="/apex/My_RIM_Programs" height="200px" width="500px"></iframe>

 

Can anyone assist me with making the appearance of this visual force page match that of the home page where it will be utilized? I've spent time searching through the help and have found a number of references to standard CSS available within salesforce but am really struggling with how to implement these styles within the VF page and what variables i.e. "Theme2", "Theme3" to use.

 

Thanks

On Contact Object there is a look up for the Account I had to validate on record type of the Account object .

 

I wrote the code as follows but it is giving compiler errror saying variable not exist

 

If(Accounts__r.RecordType.Name != 'Business')

 

Error Msg.

Hello,

 

I'm new to visualforce and think I understand it conceptually from watching the training video. I could use some help though creating my first page so I can learn it in practice...

 

I have a custom object called case notes. I want to override the home page tab to show my task list and the case note tab layout  so I can create and view my case notes straight from the home page. Any advice for which components, how the coding should look, etc would be much appreciated.

 

Thanks!