Community
Showing results for 
Search instead for 
Do you mean 
Reply

Handling image fields programmatically

Copper Contributor
Posts: 20
Country: USA

Handling image fields programmatically

One of my first contact layout customizations was to add an image field so I can have pictures of my contacts. It's amazing how much it add to relationship management.

 

Anyway, I want to sent the image programmatically via web api. I haven't yet looked hard for the SDK docs on images, but I thought I'd start here. It seems to me the process might be:

 

1. Download the image (using the URL) to my server

2. Programatically (C#) connect the image field in a contact to that newly downloaded image

 

Perhaps step 1 isn't necessary and the image field can be hooked up to the URL. In any event--is there an Act! hacker out there who knows their way around this territory?

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically (UploadFile.aspx)

Perhaps someboday has access to the codebehind for  UploadFile.aspx? (it's in Act! for Web) That dialog box has the code we need to set an image field.

 

Thanks in advance!

 

Scotty T.

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Handling image fields programmatically

Check out the contact context browser control in the dev forums.  With that control you can set the source for the control as the URL/URI of the image you want and it will handle all rendering in the layout.  The contact context browser control can accept a value from another property of the record as the source, so you would just want to capture the URL into a custom field then configure the control to use that fields value as the source.

 

Picture fields in Act! are varbinary SQL fields behind the scenes, meaning they are serialized into the database at time of assignment.  this is good for portability, but generally bad for version control and asset management.  the URL & browser control is a better overall approach for dynamically rendering imagery into Act! than using the picture control/data type.

 

 

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically

So this method (completely new approach) is somehow easier/better than adding a fewlines of C# code to my existing, working web service?  The UploadFile.aspx dialog sets an image file to an image field without regard to the contact context browswer control--doesn't it?  Why can't I do exactly what UploadFile.aspx does?

 

I don't have concerns about "asset mangement" and other things. I just want to set the image control to a jpeg. It seems like such a simple question

 

-st

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically

Perhaps I need to stress "web service" here.

 

My code allows for RESTful posting of contact data from my browser. This application MUST not rely on anything having to do with the Act! application, or extensions, or plug-ins. It MUST only be function calls on the SDK. Any reference to doing something within the Windows OR Web Application won't work for me.

 

So, what i need is the few lines of code that UploadFile.aspx uses to set an image control. In this case, I can't use alternative approaches that rely on anything besides C# calls to the libraries.

 

-st

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Handling image fields programmatically

From what I understand in your post:  your REST based web service is acquiring an asset -  a jpeg image, and it is attempting to correlate the image to a contact record and provide the asset so that it is available for display inside of Act!.

 

There are 2 approaches to do this you can 1.  Provide a reference to the asset - a URI that gets stored to Act! contact record and the Act! Client then needs to be configured to render via this reference or:

 

2. You can store a serialized version of the asset into the contact record into a field that supports picture data type.

 

UploadFile.aspx from the web client uses the second approach, if you have built a REST based web service it's a little difficult for me to understand why you would want to use this approach versus storing the asset and providing the URI, so while I'm happy to help you take approach 2 - I just want to make sure the approach selected fits what you are trying to accomplish.

 

If you have already accomplished raising an instance of the framework and setting and posting an instance of contact data then I'm guessing you have run into issues when trying to set the property for the picture field with your jpeg asset.  Can you describe if you are having issues casting your image to right data type, finding the property to set, or mapping your jpeg objects properties to the field to set?

 

Also if you could post what version of Act! you are using perhaps we can get you some sample code to set and post to a picture field.  I haven't posted to this datatype, but I see the supported datatype in the Field Descriptors, so this should be accomplishable.  I'm guessing the challenge here will be in casting the jpeg object (you want to pass to Act! the binary instance of this) in order to properly set it in your code.

 

I'm happy to discuss the other approach as well and pros/cons of both approaches.  

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically

Thank you, thank you, thank you. Finally...questions and comments that are truly on point to my question!

 

I am interested in using method #2, just like UploadFile.aspx. That is expedient for my needs. 

 

My question is basic: I don't know what the function call looks like to set the image. I don't know what method(s) is invoked. I've been unable to find a reference to that particular problem in the docs. I've taken a couple guesses based on how to set a text field, but that isn't working.

 

I imagine there are 2-3 lines of code in UploadFile.aspx that takes a URI and attaches it to my picture record. I need to see those 2-3 lines of code and I can add them to my (already working with all other fields I need) web service.

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically

[ Edited ]

Sorry, I didn't answer all your points above:

 

I'm using Act V16 Premium with the latest service pack. I've found the proper reference to TBL_CONTACT to talk to my picture field. I just don't know what to do with it. I want to replicate exactly what UploadFile.aspx does: I have a URI string in hand that I want to pass to a black box of code that takes that URI and makes it a pretty picture (200 x 200) in my Contact layout. 

 

The problems you've guessed I've had are actually beyond where I've gotten. I haven't even known how to approach setting this image...thus the stream of questions to see UploadFile.aspx.

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Handling image fields programmatically

What version of Act!?  I'll try to get you a code sample and test it myself.  

 

If you don't know the specific version of Act! just let me know if it's Act! 2012 or older as there was an interface change then that I need to account for if it's older versus newer version of Act!.

 

 

 

Copper Contributor
Posts: 20
Country: USA

Re: Handling image fields programmatically

Sorry Allen, our posts crossed in cyberspace with me giving you a better answer.

 

We've got v16 Premium with the most up to date SP.