• pjaenick.ax736
  • NEWBIE
  • 40 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 27
    Replies
Any way to *exclude* fellow System Administrators from the ".invalid" tag during a refresh?
Ok - I have a working Javascript button that executes a Conga Report - works great.

I'd like to stop pushing the button, and instead schedule the report via Scheduled Apex...

Here's my VF page and Apex class:
 
<apex:page controller="calljavascript_cls" >

    <script>
    function func() {
        window.open('https://composer.congamerge.com?sessionId={$API.Session_ID}&serverUrl={$API.Partner_Server_URL_370}.........);
    }
    </script>

    <apex:outputText value="{!callfunc}" escape="false"></apex:outputText>

</apex:page>


global class calljavascript_cls implements Schedulable {

    global static string callfunc{get;set;}

    global void execute(SchedulableContext sc) {
        calljavascript_cls();
    }

    @future(callout=true)
    public static void calljavascript_cls() {
        callfunc='<script> func(); </script>';
    }
}
Debug logs show no evidence that the VF javascript function is being invoked (?) which is making my troubleshooting efforts difficult.

Thanks for any assist / guidance,
Pete
 
Have a working javascript button.  Now I'd like to avoid pushing it :)

So I've utilized the other suggestions I've found and embedded my script in a VF page, but having trouble making the class "schedulable":
global class calljavascript_cls implements Schedulable {

    global string callfunc{get;set;}

    global void execute(SchedulableContext sc) {
        calljavascript_cls();
    }

    @future(callout=true)
    public static void calljavascript_cls() {
        callfunc='<script> func(); </script>';
    }
}

Error: Compile Error: Variable does not exist: callfunc at line 14 column 9

Thanks for any assistance,
Pete
Question - are the related list counts exposed anyplace within Apex / VF, or must I SOQL for them to get the count()?

If not, wouldn't it make sense that the be exposed, since SF is gathering them anyway on page display, (and thereby avoiding unnecessary SOQL calls?)

Thanks,
Pete
I have a trigger that needs to fire on before insert, after insert, before update and after update conditions -
 - Each invokes a different class method.
 - The before triggers (insert and update) fire on the affected record(s)
 - The after triggers (insert and update) fire on record(s) of a different object

There is also workflows that perform field updates.  But only want the update triggers to fire for existing records. 

The solutions I've seen (thus far) would work for a "before insert" vs "before update" condition, and similarly work for an "after insert" vs "after update" condition.

How do I prevent the before update and after update triggers from firing on an insert record?
Keep in mind, if the before update trigger (correctly) fires, I DO want the after update trigger to also fire.

Thanks for any strategies / guidance.
I'm trying to insert multiple records with many field assignments - mostly all the same with only one field that distinguishes one record from the next, in other words:

<my_obejct__c> mo;

            if (some_condition) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableA);
                mosToInsert.add(mo);
            }
            if (some_condition2) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableB);
                mosToInsert.add(mo);
            }
            if (some_condition3) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableC);
                mosToInsert.add(mo);
            }
            if (mosToInsert.size>0) insert mosToInsert;

Any way to define a "baseline" record for fields 1-4 and avoid all the repeated field assignments?

Thanks,
Pete
Is there a way to combine these two statements?  If there is, I haven't been able to get the syntax right :

            Case newCase = new case();
            insertCaseAndAttachEmail(newCase, email);

Thanks for any assistance !
Pete
 
I'm trying to convert my HTML sidebar component to VisualForce, but having issues.  The intent is to launch a report in the main-window with a single parameter in-tow.  The report is opening inside the tiny component rather than in the main SF window - any ideas?

Original HTML Sidebar Component :
<form method="get" action="/00O30000003yO3T">Account #: <input name="pv0"><br><input value="Submit Query" type="submit"> </form>
My VisualForce page attempt:
<apex:page >
  <form method="get" action="/00O30000003yO3T">Account #: <input name="pv0"/><br/><input value="Submit Query" type="submit"/> </form>
</apex:page>
Searching around, I tried tucking in a (target="_blank") clause, but that didn't help - I'm sure I'm not using it correctly :)

All help appreciated - thanks!
Pete
I'm trying to display the record 'name' field (auto-numbered field) on a visualforce page after insert

How can I do that?  Do I really need to re-query for it to display it after insert?

Here's my page & controller class :
--------------------------------------------------------
<apex:page standardController="MyCustomObject__c" extensions="MyCustomObjectExt">

    <apex:form >
        <apex:outputPanel id="all">
            <apex:sectionHeader title="My Custom Object" subtitle="{!MyCustomObject__c.Name}"/>  <!-- 'Name' is always null :(  -->
            <apex:outputPanel >
                <apex:commandButton action="{!SaveButton}" value="Save Me!" status="SaveButtonStatus" rerender="all"/>
            </apex:outputPanel>
        </apex:outputpanel>
    </apex:form>
</apex:page>

--------------------------------------------------------
public class MyCustomObjectExt {

    private MyCustomObject__c thisRecord;
    private ApexPages.StandardController sc = null;

    public MyCustomObjectExt(ApexPages.StandardController sc) {
        this.sc=sc;
        thisRecord = (MyCustomObject__c) sc.getRecord();
    }

    public PageReference saveButton() {
        try {
            Upsert thisRecord;
            string s = '/' + ('' + thisRecord.get('Id'));
        } catch (Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Whoops !'));
        }
        return null;
    }
}

Thank you!
Relatively new to VF - begging some guidance please :

I have a custom obj that relates to itself (contact call logs, can relate one call to a prior)

If the user (on call (C)) selects to associate prior call (B) that itself has a prior call (A), logic should take then associate (C) to (A).  (A)'s id is inserted into the lookup field of record (C).  This works fine.

What doesn't work is when (B) has no prior call.  I get a "System.TypeException: Invalid id value for this SObject type"

Here's the VF page section where I'm passing both the "ParentTo" and "ParentsParent" id's :
(can I do the null check right here in the VF page and pass a single value?)

<apex:commandButton value="Associate" action="{!Associate}" rerender="all”>
    <apex:param name="Parent" value="{!prior.id}" assignTo="{!Parent}"/>
    <apex:param name="ParentsParent" value="{!prior.First_call__c}" assignTo="{!ParentsParent}"/>
</apex:commandButton>

Controller excerpt:
91        if(ParentsParent != null) {
92            call__c ParentCall = new call__c(id=ParentsParent);

Line [92] produces the error, even though (I thought) the null-check should have avoided this line entirely.

Thanks for any assistance

Greetings!

 

If I have a list of existing records that I wish to query for existence based on Field1, Field2, and Field3, how would I ensure that I don't get a record back where List[1].Field1 matches record X, but List[1].Field2 matches some other record?

 

       ExistingContactsList=[
            SELECT Name, Email, Phone, AccountId
              FROM contact
             WHERE Name in:setNames and Email in:setEmails and Phone in:setPhones and AccountId in:setAccountIds 
            ];

 

Thanks for any help,

Pete

Is it possible to define one method within a "with sharing" class as "without sharing"?  If so, what's the correct syntax? 

 

"Error: Compile Error: Methods cannot be marked with(out) sharing"

 

I'd rather not turn off the "with sharing" clause for the entire class.

 

Thanks

Have a custom "Account Contact Role" (ACR) table here, joiner obj between Accounts and Contacts.  Any time an ACR is added, if the Contact used is missing an Account, I'd like to update that contact record with the Account.

 

I know I'm sufferening from "lazy queryness" here - after 100 different tries and fails, I'm looking for some guidance down the right path - please help !

 

Best way to "bulk friendly" grab the existing Contact Account values?

 

trigger ACR on Account_Contact_Role__c (Before Insert) {

    Map<Account_Contact_Role__c, Contact> ACRtoContactMap = new Map<Account_Contact_Role__c, Contact>();

    for (Account_Contact_Role__c ACR : trigger.new) {
        If (ACR.Contact__r.Account == null) { // <== yes, I know...will always be null 
                                              // (please help me to fix!)
            Contact C = new Contact(Id=ACR.Contact__c);
            C.AccountId=ACR.Account__c;
            ACRtoContactMap.put(ACR, C);
        }
    } 
    if(!ACRtoContactMap.isEmpty()){
        update ACRtoContactMap.values();
    }
}

 

Thanks for any asisstance / guidance !

We have a rollup field on the Account object that references a custom table - the intent of this rollup is to pull in the latest value only from the most recently posted month.  The rollup today would have filter criteria of (for example) "Posted Date equals 8/9/13".  We manually change this rollup each time we upload more data to the custom table.

 

I'm looking for a way to make this more dynamic, such that the Account obj always pulls in the "latest" data available, without having to adjust the rollup field each time.  I tried changing the rollup to instead  point to a field on the custom object called "Most Recent", defaulted to one, with an accompanying apex trigger/class to set all prior records set to one back to zero, but this caused contention (DML) issues due to the associated rollup field on the Account.

 

Any other ideas?

 

Thanks,

Pete

I'd like to detect if a lookup to an object compare a lookup field between "recordA" and "recordB".

 

Is there a more streamlined / shorthand logic approach other than :

  1.  Checking if A is Null and B is not Null OR

  2.  Checking if B is Null and A is not Null OR

  3.  A and B are both not Null and are different?

 

T-e-d-i-u-m !

 

Thanks,

Pete

 

 

Ok,

Looking for some shorthand on setting a value to zero if null in an assignment statement....

I have this :

    for(Account A: Accts) {
        MyObject__c MO = new MyObject__c(
           ...,
           MO.MyField__c = A.FieldA__c + A.FieldB__c //Errors when either FieldA or B is Null
        );
        MOsToInsert.add(MO);
    }

MyField, and Account fields FieldA and FieldB are all integers.  The above, of course, fails if either FieldA or FieldB is Null.  My sloppy work-around is to define variables for FieldA and FieldB, swapping in a zero if either is null, (requires about 10 additional lines of code).  I know there must be an easier way - perhaps an inline edit to this line to handle the null condition?  ::

(I thought this would work, but this fails too... perhaps my syntax is off?)

           MO.MyField__c = A.FieldA__c == null?0:A.FieldA__c + A.FieldB__c == null? 0:A.FieldB__c

Thanks for any assistance!

Pete

I'm trying to display the record 'name' field (auto-numbered field) on a visualforce page after insert

How can I do that?  Do I really need to re-query for it to display it after insert?

Here's my page & controller class :
--------------------------------------------------------
<apex:page standardController="MyCustomObject__c" extensions="MyCustomObjectExt">

    <apex:form >
        <apex:outputPanel id="all">
            <apex:sectionHeader title="My Custom Object" subtitle="{!MyCustomObject__c.Name}"/>  <!-- 'Name' is always null :(  -->
            <apex:outputPanel >
                <apex:commandButton action="{!SaveButton}" value="Save Me!" status="SaveButtonStatus" rerender="all"/>
            </apex:outputPanel>
        </apex:outputpanel>
    </apex:form>
</apex:page>

--------------------------------------------------------
public class MyCustomObjectExt {

    private MyCustomObject__c thisRecord;
    private ApexPages.StandardController sc = null;

    public MyCustomObjectExt(ApexPages.StandardController sc) {
        this.sc=sc;
        thisRecord = (MyCustomObject__c) sc.getRecord();
    }

    public PageReference saveButton() {
        try {
            Upsert thisRecord;
            string s = '/' + ('' + thisRecord.get('Id'));
        } catch (Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Whoops !'));
        }
        return null;
    }
}

Thank you!
Have a working javascript button.  Now I'd like to avoid pushing it :)

So I've utilized the other suggestions I've found and embedded my script in a VF page, but having trouble making the class "schedulable":
global class calljavascript_cls implements Schedulable {

    global string callfunc{get;set;}

    global void execute(SchedulableContext sc) {
        calljavascript_cls();
    }

    @future(callout=true)
    public static void calljavascript_cls() {
        callfunc='<script> func(); </script>';
    }
}

Error: Compile Error: Variable does not exist: callfunc at line 14 column 9

Thanks for any assistance,
Pete
I have a trigger that needs to fire on before insert, after insert, before update and after update conditions -
 - Each invokes a different class method.
 - The before triggers (insert and update) fire on the affected record(s)
 - The after triggers (insert and update) fire on record(s) of a different object

There is also workflows that perform field updates.  But only want the update triggers to fire for existing records. 

The solutions I've seen (thus far) would work for a "before insert" vs "before update" condition, and similarly work for an "after insert" vs "after update" condition.

How do I prevent the before update and after update triggers from firing on an insert record?
Keep in mind, if the before update trigger (correctly) fires, I DO want the after update trigger to also fire.

Thanks for any strategies / guidance.
I'm trying to insert multiple records with many field assignments - mostly all the same with only one field that distinguishes one record from the next, in other words:

<my_obejct__c> mo;

            if (some_condition) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableA);
                mosToInsert.add(mo);
            }
            if (some_condition2) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableB);
                mosToInsert.add(mo);
            }
            if (some_condition3) {
                mo = new my_object__c(field1__c = 1, field2__c = 'test', field3__c = 'banana', field4__c = 3.14, field5__c = variableC);
                mosToInsert.add(mo);
            }
            if (mosToInsert.size>0) insert mosToInsert;

Any way to define a "baseline" record for fields 1-4 and avoid all the repeated field assignments?

Thanks,
Pete
Is there a way to combine these two statements?  If there is, I haven't been able to get the syntax right :

            Case newCase = new case();
            insertCaseAndAttachEmail(newCase, email);

Thanks for any assistance !
Pete
 
I'm trying to display the record 'name' field (auto-numbered field) on a visualforce page after insert

How can I do that?  Do I really need to re-query for it to display it after insert?

Here's my page & controller class :
--------------------------------------------------------
<apex:page standardController="MyCustomObject__c" extensions="MyCustomObjectExt">

    <apex:form >
        <apex:outputPanel id="all">
            <apex:sectionHeader title="My Custom Object" subtitle="{!MyCustomObject__c.Name}"/>  <!-- 'Name' is always null :(  -->
            <apex:outputPanel >
                <apex:commandButton action="{!SaveButton}" value="Save Me!" status="SaveButtonStatus" rerender="all"/>
            </apex:outputPanel>
        </apex:outputpanel>
    </apex:form>
</apex:page>

--------------------------------------------------------
public class MyCustomObjectExt {

    private MyCustomObject__c thisRecord;
    private ApexPages.StandardController sc = null;

    public MyCustomObjectExt(ApexPages.StandardController sc) {
        this.sc=sc;
        thisRecord = (MyCustomObject__c) sc.getRecord();
    }

    public PageReference saveButton() {
        try {
            Upsert thisRecord;
            string s = '/' + ('' + thisRecord.get('Id'));
        } catch (Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Whoops !'));
        }
        return null;
    }
}

Thank you!
Relatively new to VF - begging some guidance please :

I have a custom obj that relates to itself (contact call logs, can relate one call to a prior)

If the user (on call (C)) selects to associate prior call (B) that itself has a prior call (A), logic should take then associate (C) to (A).  (A)'s id is inserted into the lookup field of record (C).  This works fine.

What doesn't work is when (B) has no prior call.  I get a "System.TypeException: Invalid id value for this SObject type"

Here's the VF page section where I'm passing both the "ParentTo" and "ParentsParent" id's :
(can I do the null check right here in the VF page and pass a single value?)

<apex:commandButton value="Associate" action="{!Associate}" rerender="all”>
    <apex:param name="Parent" value="{!prior.id}" assignTo="{!Parent}"/>
    <apex:param name="ParentsParent" value="{!prior.First_call__c}" assignTo="{!ParentsParent}"/>
</apex:commandButton>

Controller excerpt:
91        if(ParentsParent != null) {
92            call__c ParentCall = new call__c(id=ParentsParent);

Line [92] produces the error, even though (I thought) the null-check should have avoided this line entirely.

Thanks for any assistance

Greetings!

 

If I have a list of existing records that I wish to query for existence based on Field1, Field2, and Field3, how would I ensure that I don't get a record back where List[1].Field1 matches record X, but List[1].Field2 matches some other record?

 

       ExistingContactsList=[
            SELECT Name, Email, Phone, AccountId
              FROM contact
             WHERE Name in:setNames and Email in:setEmails and Phone in:setPhones and AccountId in:setAccountIds 
            ];

 

Thanks for any help,

Pete

Is it possible to define one method within a "with sharing" class as "without sharing"?  If so, what's the correct syntax? 

 

"Error: Compile Error: Methods cannot be marked with(out) sharing"

 

I'd rather not turn off the "with sharing" clause for the entire class.

 

Thanks

Hi !

 

I have this trigger to send e-mail based on the field "e_mail__c":

 

trigger Email_EnviodeLayout_AR on Task (after update) {
    
  List<Id> TaskMap = new List<Id>();
    for(Task tsk : [select e_mail__c, subject, link_do_ar__c, status from Task])
    {
        if(tsk.subject == 'AR - Envio do primeiro layout' && tsk.status == 'Concluído')
        {        
	        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
	        String[] toAddresses = new String[] {tsk.e_mail__c};
	        mail.setToAddresses(toAddresses);
	        mail.setSubject('Duomind');
	        String template = 'Hello {0}, \nYour task has been modified. Here are the details - \n\n';
	        template+= 'Veja suas fotos clicando aqui - {1}\n';   
	            
	        List<String> args = new List<String>();
	        args.add(tsk.link_do_ar__c);
	       
	        // Here's the String.format() call.
	        String formattedHtml = String.format(template, args);
	       
	        mail.setPlainTextBody(formattedHtml);
	        Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
	    }
    }
}

 But It's giving me this error:

 

  • Email_EnviodeLayout_AR: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature.: [] Trigger.Email_EnviodeLayout_AR: line 22, column 1

Greetings Listers,

 

Within an Apex class, I'm looping through and building a string thusly :

 

  mystring += eachrecord.Quantity__c + '         ' + eachrecord.Item__c + '\n';

 

After setting the target field to this value, when displaying this value in a report (or an alert), the whitespace between the Quantity and Item values is compressed to a single space.  How can I prevent this?

 

Thanks,

Pete

Hi,

Am unable to refresh any of the resources in the IDE from the server.

When am trying to refresh a page from the web, getting an Exception saying:

 

 

Unable to refresh resource 'MileaeExension.cls':
com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Unable to refresh resource 'MileaeExension.cls':


com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Please assist to rectify the issue. 

 

Thanks in advance,

VNath