You are viewing limited content. For full access, please sign in.

Question

Question

C#.net in workflow

asked on August 5, 2021

Hi,

I want to change the field - 'Name' to 'Full Mobile' - These fields are from another website, but just change the text to FullMoblie is wrong, it can't get the value. So I want to know where I miss to set up? Thanks for your help.

0 0

Replies

replied on August 5, 2021

Maybe try changing

var ReturnContactResult = serializer.Deserialize<ApiContactResult>...

to

var ReturnContactResult = serializer.Deserialize<Contact>...

ApiContactResult may be defined somewhere else.  But if you intend to deserialize to the Contact class, I think that once the class name is set correctly, you should be able to make some progress.  Alternatively, you could set up an HTTP Web Request activity to do this.

0 0
replied on August 5, 2021 Show version history

Hi Peter,

Yes, ApiContactResult is defined somewhere else. The logic is my workflow now is correct, but I want to add a new field - "Full Moblie". just add 'public string Full_Moblie {get; set;}' and 'SetTokenValue("Account_Full_Moblie", ReturnContactsResult.records[0].Full_Moblie);' can't get value. I don't know where to see and set up the JSON.  I don't know how to get the value of 'Full Moblie' from other website.

 

0 0
replied on August 6, 2021

Doris,

I think your first web request is just receiving a token which you can then use to access a REST API endpoint.  I haven't done a Salesforce integration so I'm not familiar with how their authentication is set up.  Here's an example of how I got an InsureSign API to function (note: I'm not advocating for InsureSign - I ended up finishing this project with DocuSign which works the same way).  Hopefully, you can apply this to Salesforce.

There's a couple things to note here.  First I've circled the gear icon in red.  This gives you access to extra settings for the web request.  Second, I'm using an authorization header to get my access token.  If your client id/client secret requests gets you an authorization token, stick with that.  If not, you will likely need to log into Salesforce and figure out how to generate your authorization code.  If I remember correctly, the code I used was a hash of the clent id and client secret that I received by logging in to my account and setting up my api.

For some reason, I used a toolkit script to parse out my access token.  I think the ReadJSON activity as you have it should handle this just fine.  In fact, it looks like you already have an "access_token" configured.  Assuming you have an access token working properly, it is time to use it to retrieve information:

This request just retrieves a list of documents.  Note that I'm passing my access token into the header for the request.  I'm also specifying the /documents endpoint in the URI.  The result of the request is information about the documents in JSON format.  You would use a similar command with Salesforce.  Here's an example (I of course don't know if this is the API you are using or if this is the correct endpoint as I'm unfamiliar with the API): REST API Developer Guide | Get Field Values from a Standard Object Record (salesforce.com)

If you aren't familiar with Postman, it is worth looking into.  Postman lets you set up and test REST APIs.  With Docusign, all I had to do was configure the Postman environment for the Docusign collection and all the command examples just ran.  Like Docusign, they probably have an extensive collection of Salesforce examples already put together. It is a good way to test things out before implementing the workflow activities.

0 0
replied on August 5, 2021

The serializer is what maps attributes in the response to object properties. If you want it to map differently, you need to give it instructions. The exact mechanics will be different depending on which serializer you are working with, but it'll be something like this https://stackoverflow.com/questions/15915503/net-newtonsoft-json-deserialize-map-to-a-different-property-name.

0 0
replied on August 5, 2021 Show version history

Hi Brian, 

Thanks for your answer, where to set up the JSON is exactly my question, I check my workflow about 'HTTP Web Request ', it didn't appear like 'Name' and 'Title' and 'Email'.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.