Box Integration

The following is code based on some suggestions on this community (thanks to all). We are using a custom Object called Service_Type__c and the Model is Service. I get the page to display in a tab, but the authentication error shows and even when putting in my credentials, it fails. Anything stand out?

token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_URL_120}}}

%22%2C%22session_id%22%3A%22{{$Api.Session_ID}}%22%7D&

salesforce_object_typed_id={{{$Model.Service.data.0.Id}}}

&partner_object_type=Service_Type__c&partner_object_name={{{$Model.Account.data.0.Id}}}

&partner_object_email=&partner_object_id={{$Param.Id}}

&open_new_window=1&partner_user_id={{{$Model.RunningUser.data.0.Id}}}

&partner_user_name={{$Model.RunningUser.data.0.FirstName}}%20

{{$Model.RunningUser.data.0.LastName}}&partner_user_email={{$Model.RunningUser.data.0.Email}}

&email_recipients=&debug=0" width="100%" height="800" scrolling="true" id="theIframe"/>

Try this instead — the two $Api merges were incorrect, I fixed them according to the syntax documented here in the Global Merge Variables / functions API docs.

Zach,
Thanks but same result with the following code. Changed a bad reference to Model.Account to Model.Service, but no change. I get the authentication page and can’t login.

Do you have a running user model?  This line  {{$Model.RunningUser.data.0.Id}}  is looking for information about the current user.  It provides the user information necessary for authentication.  If you don’t want to build a model, you could also use global merge syntax to get this information about the user,  rather than creating a model and referring to it.  Look at the document Zach provided for that syntax. 

We created a Model called RunningUser and pointed to the User Object, It has 4 fields, ID, First Name, Last Name and Email address. It has a condition of the User records of the User Id is the User Id of the user running this page and alway on. 

Ben, {{{$Api.Session_ID}}}needs to have a lowercase d: {{{$Api.Session_Id}}}

Also, the first part of the URL looks suspect to me: "https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_Urls…
%22%2C%22session_id%22%3A%22{{{$Api.Session_ID}}}%22%7D 

Maybe it’s correct, but would you mind posting where you found this code / iframe embed link?


Zach,
Thanks. It is the VF page for the box element:
<apex:page standardController=“Service_Type__c”>

<apex:stylesheet value="{!$Resource.box__BoxFilesCSS}" /> <apex:iframe src="https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{!URLENCODE($Api.Partner_Server_URL_120)}%22%2C%22session_id%22%3A%22{!URLENCODE($Api.Session_ID)}%22%7D&amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}&amp;partner_object_type=Account&amp;partner_object_name={!URLENCODE(Service_Type__c.name)}&amp;partner_object_email=&amp;partner_object_id={!$CurrentPage.parameters.Id}&amp;open_new_window=1&amp;partner_user_id={!URLENCODE($User.Id)}&amp;partner_user_name={!URLENCODE($User.FirstName)}%20{!URLENCODE($User.LastName)}&amp;partner_user_email={!URLENCODE($User.Email)}&amp;email_recipients=&amp;debug=0" width="100%" height="800" scrolling="true" id="theIframe"/> </apex:page> Just sort of modified what we posted based on comments in the forum.

Thanks for posting the code. This is a usually just a big exercize in replacing merge statements. 


After taking apart the query strings here are all the merge statements and the equivalent Skuid Merge statement.  

  • {!URLENCODE($Api.Partner_Server_URL_120)} = {{#urlEncode}}{{$Api.Enterprise_Server_Urls.120}}{{/urlEncode}}

  • {!URLENCODE($Api.Session_ID)} = {{#urlEncode}}{{$Api.Session_Id}}{{/urlEncode}}

  • {!$CurrentPage.parameters.Id} = {{$Param.id}}    (This depends on a URL Param named “id” being passed into the page.)

  • {!URLENCODE(Service_Type__c.name)}  = {{#urlEncode}}{{$Model.ServiceType.data.0.Name}}{{/urlEncode}}  (This depends on a model with the Name “ServiceType” and the field “Name” being present on the page) 

  • {!URLENCODE($User.Id)} = {{#urlEncode}}{{$User.userId}}{{/urlEncode}}

  • {!URLENCODE($User.FirstName)}  = {{#urlEncode}}{{$User.firstName}}{{/urlEncode}}

  • {!URLENCODE($User.LastName)} = {{#urlEncode}}{{$User.lastName}}{{/urlEncode}}

  • {!URLENCODE($User.Email)} = {{#urlEncode}}{{$User.email}}{{/urlEncode}}


After all that replacement,  here is the resulting iFrame code: 

iFrame src="<a target="_blank" rel="nofollow" href="https://www.box.com/widget_sso/salesforce">https://www.box.com/widget_sso/salesforce<br></a>?token=%7B%22server_url%22%3A%22{{#urlEncode}}{{$Api.Enterprise_Server_Urls.120}}{{/urlEncode}}%22%2C%22session_id%22%3A%22{{#urlEncode}}{{$Api.Session_Id}}{{/urlEncode}}%22%7D<br>&amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}<br>&amp;partner_object_type=Account&amp;partner_object_name={{#urlEncode}}{{$Model.ServiceType.data.0.Name}}{{/urlEncode}}<br>&amp;partner_object_email=<br>&amp;partner_object_id={{$Param.id}}<br>&amp;open_new_window=1<br>&amp;partner_user_id={{#urlEncode}}{{$User.userId}}{{/urlEncode}}<br>&amp;partner_user_name={{#urlEncode}}{{$User.firstName}}{{/urlEncode}}%20{{#urlEncode}}{{$User.lastName}}{{/urlEncode}}<br>&amp;partner_user_email={{#urlEncode}}{{$User.email}}{{/urlEncode}}<br>&amp;email_recipients=<br>&amp;debug=0" &nbsp;<br>width="100%" height="800" scrolling="true" id="theIframe"



Hopefully this works for you. 

<br>

Thanks and we have tried this with no luck. We have a Model defined called “Service” and the Name field is called Service__c, under the model which is the “Service” field on the Service_Type__c object (i.e. Service__c). As for the Param.id, not sure where that would be set as box uses the ID of the record it is on to display the folder/files of the related object. 
When this code loads in the skuid UI, we are getting the authentication dialog, so we are not getting past the authentication and so not sure we can even see if the rest of the params are correct. Truly appreciate the effort.

Ok.  Let’s debug… 

Go to the rendered page.  Select the BOX.Com section of the page and right click and “Inspect Element” 

Find the iframe code and copy what is there.   Here is a picture from another third party integration. 



I ususally paste the iFrame code into a text editor and compare it with the code I put into the Skuid Template to ensure that all the merge fields are getting correctly the expected data. 

When I see Id’s that are mysterious.  I plug them into a salesforce url   ( https://skuid.na3.visual.force.com/PUT_ID_HERE )

This should show you what data is not getting pulled into your Box integration. 

?token=%7B%22server_url%22%3A%22%22%2C%22session_id%22%3A%2200DA0000000HFfX!AREAQO2841zUs7xV3.hbzt469kkmcsSVOB.SGjhnvQjYcosMNJj9NoC95qybEbRIePaQ6joQdTmylfCoE17WDbVKJOOTb2Xo%22%7D

&amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}

&amp;partner_object_type=Account&amp;partner_object_name=

&amp;partner_object_email=

&amp;partner_object_id=a0qF0000006gf3IIAQ

&amp;open_new_window=1

&amp;partner_user_id=005A0000000HnhrIAC

&amp;partner_user_name=Fred%20Flintstone

&amp;partner_user_email=Fred.Flintstone%40bedrock.com

&amp;email_recipients=

&amp;debug=0" width="100%" height="800" scrolling="true" id="theIframe">

Ooh I see two things. 

1. Look at this line: 

&amp;amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}

You say above "box uses the ID of the record it is on to display the folder/files of the related object. " 

If you are building a detail page for “Service_Type_c” records,  you probably have a condition on “Service” model that filters down records to one ID.  Usually this is done with a URL parameter.  Whatever this parameter is,  can be re-used here.   If the URL parameter is “Id”  your line needs to read: 

&amp;amp;salesforce_object_typed_id={{$Param.Id}}


2. Look at this line. 

&amp;partner_object_type=Account&amp;partner_object_name=

For whatever reason,  no data is getting populated there.  You said: “We have a Model defined called “Service” and the Name field is called Service__c, under the model which is the “Service” field on the Service_Type__c object (i.e. Service__c).”   If this is the case, the merge syntax needs to be:  “{{$Model.Service.data.0.Service__c}}”  

The rest looks correct. 

One sec, I think I had cached data. Checking again and will post results.

I did a comparison (sent via email) between what is being rendered and what works in our production environment.

Basically a couple things stand out.

First, the Api.Enterprise_Server_Url.120 is not being set on the Skuid object. 

{!URLENCODE($Api.Partner_Server_URL_120)} is what Box is using in the current VF page and {{$Api.Enterprise_Server_Urls.120}} is what you sent me to use.

Second, the Skuid object is using the 18 digit ID of the object and box using the 15 digit.

Third, I have the object type wrong in Skuid.

{{$Api.Partner_Server_Urls.12}} should be used in Skuid, not {{$Api.Enterprise_Server_Urls.120}} (remove the zero at the end), and use Partner instead of Enterprise.

More than likely the “Skuid object” that you need to pass in to Box is the first row in a Model in your page. Say that the object record is your Service model (I don’t know if this is true), then you can get the 15-digit Id of this record by doing this:

&amp;salesforce_object_typed_id={{{$Model.Service.data.0.Id15}}}


Well after all the input provided, using pieces of each, and much trial and error, we have it working on a custom object. I am going to try and use this same code on another custom object that is a little different and then will send you a pdf of the steps I took and details of how we all got this working, for future reference.
Much appreciated.

WOOT!  Sorry for the trials and tribulations.  We appreciate your patience. 

Thanks for this post - it has been very helpful. I was able to embed Box within a Skuid tab for the Opportunity object, however, if there is an associated box folder already created it will not show when the tab loads. Instead, it prompts you to create a new folder to associate with the salesforce record.

I’m assuming it has something to do the with folder ID on the box side of things? Does anyone know how to grab an existing salesforce-box folder for a specific record?

Thanks.

If your setup is accurate (the setup of the SKUID TEMPLATE), then you should see the associated folder, if one existed already. If you are not seeing the folder then your variables are not correct. For instance, our environment has a root folder of SF, and a specific service object 1209298 has a box folder created with 3 pdf’s. The SKUID template needs to be able to read the ID of the object 1209298. If you inspect the page and find the template url, you should see a variable called partner_object_Id= followed by the id (found in the sf url) of the object that has the attachments. If this field is blank, then the variable is not being passed. If the field has a value, then something else is not setup correctly. In the Box “Menu Bar” you should also see the path to at least the root folder, and if not then something else could be wrong as well, but I would guess it is the Object Id.

Hi Ben,

Thank you for the help and quick response! Using your logic to hunt down the issue, I found that changing {{$Param.Id15}} to {{$Model.Opp.data.0.Id15}} (even though the Opp is the param id) allowed the information to flow into the partner_object_Id. I don’t understand why, but it worked!

Thanks again.
Chelsea