• Marco Zeuli
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 9
    Replies
On a standard object layout when you inline edit a single field, all the fields displayed on the layout are updated. Could be possible that only the field(s) that have been modified are updated?
Consider this scenario:
  • You are using the Service Console
  • You have an Account open as primary tab
  • You have a Case related to the account, open as a sub tab
  • You close the case using the standard Close button
  • Upon the case closure, an apex trigger will update a field called Status on the account from value "OLD_VALUE" to "NEW_VALUE"
  • You go back to account primary tab, where the status field is still showing as "OLD_VALUE"
  • You inline edit ONLY the account description and Save
As a result, account Status value is again "OLD_VALUE". Saving the account record after an inline edit will override the Status field also (and all others present on layout).
Hi all,

I'm writing today because I need to clarify something about the Custom Metadata Types.
Here's my doubt:

let's say we have a Custom Metadata Type named X__mdt, with a Subscriber Editable field Y__c of type Text, we have a record named Z and that Z.Y__c is equals to "Yes". Record Z was deployed to Production Org using the Ant Migration Tool by our Developers.

Now due to a business needs an Administrator, in Production Org, updates record Z setting Y__c to "No".
What happen if a Developer makes a deploy, always using the Ant Migration Tool, and the package contains the record Z but with the field Y__c set to "Yes"?

According to the doc:
"Subscriber editable—Anyone with the correct permissions can change the value of the field at any time. Changes deployed by the developer don’t overwrite values in the subscriber’s organization."

What I were expecting was that after the deploy record Z would not be overwritten by the deploy, so field Y__c would still be set to "No".
I made a test, and that's not true. Record Z gets overwritten and the value of Y was back to "Yes".

What m'I missing here ?! 
 
Hi all,

today i'm facing some issues with the queueable interface.

This is my use case:
i gave to send an email with a pdf attachment when an object is created.

This is my solution:
When user create a record, a queueable class is instantiated and enqueued in the apex job queue. The queueable class receive the Account as input and than create the PDF and send it by email.

This is my problem:
the generated job stuck in the queue for hours until a System Error is returned.

This is my code:
page to render as pdf
<apex:page showHeader="true" sidebar="true" controller="TestQueueAndPDFCtrl" renderAs="{!renderAs}">	
	<apex:outputText value="test content {!accid}" />
</apex:page>

this is the page controller
public with sharing class TestQueueAndPDFCtrl {
	
	public String accid {get;set;}
	public String renderAs {get;set;}

	public TestQueueAndPDFCtrl() {
		// get account id from parameter and set on the page
		accid = ApexPages.currentPage().getParameters().get('accId');
		renderAs = ApexPages.currentPage().getParameters().get('renderAs');
	}

	public static void sendPdf() {

		/* create an account and then send the id by email */

		Account a = new Account();
		a.Name = 'marco';
		insert a;

		Id job = System.enqueueJob(new TestQueueableWithCallout(a));
	}
}

It has also a static method to enqueue the job.

this is the queueable class
public class TestQueueableWithCallout implements Queueable, Database.AllowsCallouts {
	
	private Account a;

	public TestQueueableWithCallout(Account a) {
		this.a = a;
	}

	public void execute(QueueableContext context) {

		System.debug('queueble started!!!');

		PageReference pdf = Page.TestQueueAndPDF;
		pdf.getParameters().put('accId', a.id);
		pdf.getParameters().put('renderAs', 'PDF');

		Blob b = pdf.getContentAsPDF();
		// Blob b = Blob.valueOf('ciao');

		Messaging.EmailFileAttachment att = new Messaging.EmailFileAttachment();
		att.setFileName('ciao.pdf');
		att.setbody(b);

		Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
		mail.setToAddresses(new List<String>{'m.****@****.it'});
		mail.setsubject('test');
		mail.setFileAttachments(new List<Messaging.EmailFileAttachment>{att});
		mail.sethtmlbody('body');

		Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

		System.debug('done');
	}
}

In my ORD i enabled the critical update from SUmmer 15, so the getContentAsPDF behave as a callout.

Could you help me with this?
Hi guys,

today i'm facing a problem with the highlight panel in the Service Cloud Console.
Basically the problem is this:
  1. I open a Case as a sub tab of an Account record
  2. Highlight panel opens with some Accounts fields
  3. Click Edit button on Case detail view
  4. Edit button send the sub tab to a custom VF page to edit Case fields
  5. Click Save button on VF page to store Case data
  6. Before the VF page unload, i call from javascript the function to refresh the primary tab. That's because when i save a Case the controller action executed modify also some fields on the Account record
  7. If i click on the Deatil subtab of the Account record i can see the fields correctly updated.
  8. but the same field on the highlight panel shows the old value!
So my question is: is the call 
sforce.console.refreshPrimaryTabById
supposed to refresh also the data in the highlight panel? Is that possible that the user has to refresh the entire console to see that fields correctly updated ?!

Thanks guys ;)
 
Hi guys,

i have a doubt:

with new release Summer 15 it's said to:
You can include JavaScript in your Visualforce page, but because the component is rendered in an iframe on the home page layout, the JavaScript can’t interact with the page that contains the component.

So my question is:

If i have an Homepage Visualforce component, with this element inside:
<apex:column headerValue="Work Approval" id="workApproval">            
              <button type="button" onclick="window.top.location.href = '{!URLFOR(o.link)}'">Work</button>
</apex:column>

Will the "onclick" action still works? Or not, because it interact with the parent window?

Thxs guys ;)
i have the following problem:

I made an Homepage Visualforce component to show some info to my customers.
 
<apex:page controller="UserApprovalProcessCtrl" showHeader="true" sidebar="true" >
    <apex:pageBlock html-width="100%">
         my content
    </apex:pageBlock>
</apex:page>
The problem i'm facing is the following:

if I set the attribute showHeader="true" on the apex:page element in my VF page the result is the following:
User-added image

As you can see the component width is different from the others... If i set the attribute showHeader="false" the problem doesn't occur anymore. But i don't want to do that because i want my component to have the Home tab style.

Any idea how to resolve this?
Thank you guys ;)
 

Hi guys!

Today i need your help with an issue I'm facing at work...

I hve the following custom controller:
 

public with sharing myCustomController {

	public Map<String, wrapperObj> myMap {
	    get {
	        // populate map...
	    set;
	}

	// methods and stuffs...

	public class wrapperObj {
	    public String label;

	    public wrapperObj() {}
	}

}

And this VF page related to my custom controller
 
<apex:page controller="myCustomController">
<apex:form id="myForm">
    <apex:pageBlock >
            <!-- Map values -->
            <apex:repeat value="{!myMap}" var="key">                                    
                // this works fine
                <apex:outputText value="{!key}" />
                // this works too
                <apex:outputText value="{!myMap[key]}" />
                // this not !!
                <apex:outputText value="{!myMap[key].label}" />

            </apex:repeat>
    </apex:pageBlock>
</apex:form>

Basically I cannot figureout how to bind the wrapper object values on the page. Tryng to render the page I get this error:
 
Unknown property 'myCustomCotroller.wrapperObj.label'
Error is in expression '{!myMap[key].label}' in component <apex:outputText> in page

Thanks for your help in advance!! :)
Hi guys,
i want to share with you a solution I come up with, to wrap long url when rendering a VF page.
Basically the problem was this:
A customer pasted a very long URL (more than 400 chars) in a Rich Text Area. When rendering the page as PDF, to print it, the URL overflow the page margin, so it wasn't visible at all.

This is the code i come up with
private String addWhiteSpaceInUrlTooLong(String text) {
        // Step 1 - Search anchor links
        Pattern ptn = Pattern.compile('<a[^>]*(>.*?)</a>'); // WATCH OUT! This regex doesn't match nested anchor
        Matcher mch = ptn.matcher(text);
        Integer charPerLine = 50; // A whitespace is inserted each charPerLine chars
        while (mch.find()) {
            String toReplace = mch.group(1);
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine) //No need to replace
                continue;

            Integer elems; // White space to insert

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);            
        }

        // Step 2 - Search pasted links
        ptn = Pattern.compile('\\b\\s(https?://\\S.*?)(\\s|$)');
        mch = ptn.matcher(text);
        charPerLine = 60;

        while(mch.find()) {
            String toReplace = mch.group();
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine)
                continue;

            Integer elems;

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);
        }

        return text;
    }

You could use like this:
MyCustomObject.richText = addWhiteSpaceInUrlTooLOng(MyCustomObject.richText);
Hope it will be useful ;)
 
Hi guys,
i want to share with you a solution I come up with, to wrap long url when rendering a VF page.
Basically the problem was this:
A customer pasted a very long URL (more than 400 chars) in a Rich Text Area. When rendering the page as PDF, to print it, the URL overflow the page margin, so it wasn't visible at all.

This is the code i come up with
private String addWhiteSpaceInUrlTooLong(String text) {
        // Step 1 - Search anchor links
        Pattern ptn = Pattern.compile('<a[^>]*(>.*?)</a>'); // WATCH OUT! This regex doesn't match nested anchor
        Matcher mch = ptn.matcher(text);
        Integer charPerLine = 50; // A whitespace is inserted each charPerLine chars
        while (mch.find()) {
            String toReplace = mch.group(1);
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine) //No need to replace
                continue;

            Integer elems; // White space to insert

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);            
        }

        // Step 2 - Search pasted links
        ptn = Pattern.compile('\\b\\s(https?://\\S.*?)(\\s|$)');
        mch = ptn.matcher(text);
        charPerLine = 60;

        while(mch.find()) {
            String toReplace = mch.group();
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine)
                continue;

            Integer elems;

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);
        }

        return text;
    }

You could use like this:
MyCustomObject.richText = addWhiteSpaceInUrlTooLOng(MyCustomObject.richText);
Hope it will be useful ;)
 
Hi all,

today i'm facing some issues with the queueable interface.

This is my use case:
i gave to send an email with a pdf attachment when an object is created.

This is my solution:
When user create a record, a queueable class is instantiated and enqueued in the apex job queue. The queueable class receive the Account as input and than create the PDF and send it by email.

This is my problem:
the generated job stuck in the queue for hours until a System Error is returned.

This is my code:
page to render as pdf
<apex:page showHeader="true" sidebar="true" controller="TestQueueAndPDFCtrl" renderAs="{!renderAs}">	
	<apex:outputText value="test content {!accid}" />
</apex:page>

this is the page controller
public with sharing class TestQueueAndPDFCtrl {
	
	public String accid {get;set;}
	public String renderAs {get;set;}

	public TestQueueAndPDFCtrl() {
		// get account id from parameter and set on the page
		accid = ApexPages.currentPage().getParameters().get('accId');
		renderAs = ApexPages.currentPage().getParameters().get('renderAs');
	}

	public static void sendPdf() {

		/* create an account and then send the id by email */

		Account a = new Account();
		a.Name = 'marco';
		insert a;

		Id job = System.enqueueJob(new TestQueueableWithCallout(a));
	}
}

It has also a static method to enqueue the job.

this is the queueable class
public class TestQueueableWithCallout implements Queueable, Database.AllowsCallouts {
	
	private Account a;

	public TestQueueableWithCallout(Account a) {
		this.a = a;
	}

	public void execute(QueueableContext context) {

		System.debug('queueble started!!!');

		PageReference pdf = Page.TestQueueAndPDF;
		pdf.getParameters().put('accId', a.id);
		pdf.getParameters().put('renderAs', 'PDF');

		Blob b = pdf.getContentAsPDF();
		// Blob b = Blob.valueOf('ciao');

		Messaging.EmailFileAttachment att = new Messaging.EmailFileAttachment();
		att.setFileName('ciao.pdf');
		att.setbody(b);

		Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
		mail.setToAddresses(new List<String>{'m.****@****.it'});
		mail.setsubject('test');
		mail.setFileAttachments(new List<Messaging.EmailFileAttachment>{att});
		mail.sethtmlbody('body');

		Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

		System.debug('done');
	}
}

In my ORD i enabled the critical update from SUmmer 15, so the getContentAsPDF behave as a callout.

Could you help me with this?
Hi guys,

today i'm facing a problem with the highlight panel in the Service Cloud Console.
Basically the problem is this:
  1. I open a Case as a sub tab of an Account record
  2. Highlight panel opens with some Accounts fields
  3. Click Edit button on Case detail view
  4. Edit button send the sub tab to a custom VF page to edit Case fields
  5. Click Save button on VF page to store Case data
  6. Before the VF page unload, i call from javascript the function to refresh the primary tab. That's because when i save a Case the controller action executed modify also some fields on the Account record
  7. If i click on the Deatil subtab of the Account record i can see the fields correctly updated.
  8. but the same field on the highlight panel shows the old value!
So my question is: is the call 
sforce.console.refreshPrimaryTabById
supposed to refresh also the data in the highlight panel? Is that possible that the user has to refresh the entire console to see that fields correctly updated ?!

Thanks guys ;)
 
i have the following problem:

I made an Homepage Visualforce component to show some info to my customers.
 
<apex:page controller="UserApprovalProcessCtrl" showHeader="true" sidebar="true" >
    <apex:pageBlock html-width="100%">
         my content
    </apex:pageBlock>
</apex:page>
The problem i'm facing is the following:

if I set the attribute showHeader="true" on the apex:page element in my VF page the result is the following:
User-added image

As you can see the component width is different from the others... If i set the attribute showHeader="false" the problem doesn't occur anymore. But i don't want to do that because i want my component to have the Home tab style.

Any idea how to resolve this?
Thank you guys ;)
 

Hi guys!

Today i need your help with an issue I'm facing at work...

I hve the following custom controller:
 

public with sharing myCustomController {

	public Map<String, wrapperObj> myMap {
	    get {
	        // populate map...
	    set;
	}

	// methods and stuffs...

	public class wrapperObj {
	    public String label;

	    public wrapperObj() {}
	}

}

And this VF page related to my custom controller
 
<apex:page controller="myCustomController">
<apex:form id="myForm">
    <apex:pageBlock >
            <!-- Map values -->
            <apex:repeat value="{!myMap}" var="key">                                    
                // this works fine
                <apex:outputText value="{!key}" />
                // this works too
                <apex:outputText value="{!myMap[key]}" />
                // this not !!
                <apex:outputText value="{!myMap[key].label}" />

            </apex:repeat>
    </apex:pageBlock>
</apex:form>

Basically I cannot figureout how to bind the wrapper object values on the page. Tryng to render the page I get this error:
 
Unknown property 'myCustomCotroller.wrapperObj.label'
Error is in expression '{!myMap[key].label}' in component <apex:outputText> in page

Thanks for your help in advance!! :)
Hi All,

In the standard homepage I've inserted a custom HTML component that contains an iframe to a Visualforce Page.
In this page I've inserted a button.
I would that when the button is clicked, the homepage is redirected to another page, and not the iframe as is now.

How I accomplish it.

Thanks in advance.

In Service cloud console we have a custom edit button on account which redirects to a vf page. There is a custom Save button on this page. If we change any data(like phone number ) and save it, the new info is not refreshed in the highlights panel.

However if we use the standard edit page or inline edit the highlights panel is automatically refreshed to show the update info.

 

Is there a way to just refresh the hightlights panel?

 

Thanks in Advance.

In Service cloud console we have a custom edit button on account which redirects to a vf page. There is a custom Save button on this page. If we change any data(like phone number ) and save it, the new info is not refreshed in the highlights panel.

However if we use the standard edit page or inline edit the highlights panel is automatically refreshed to show the update info.

 

Is there a way to just refresh the hightlights panel?

 

Thanks in Advance.