july 2013 breaking changes - object create action - ruby-on-rails-3

I have a facebook app with a single custom action (earn) and a single custom object (badge). I create these objects for user from my server via POST to
'https://graph.facebook.com/' + fb_user_id + '/itsbeta:earn'
and send parameters
access_token => user_access_token,
badge => badge.fb_url
where badge.fb_url contains og-tags.
Everything works fine at the moment.
But when I enable July 2013 migration, I start getting errors
A post action for this object already exists.,
code :1611231
Seems to be the case of deprecated feature "Duplicate creation actions for the same Open Graph object", BUT in the settings of Badge Object on Advanced tab I don't have any field called "Create action", instead I have "Subscribe action", with a single action name there:
Subscribe Action: earn
What's wrong?

Related

How to create "Round Robin Call Forwarding Function" in Twilio Stack

I have researched high and low through multiple websites and have not found a single fully documented solution for round-robin call forwarding with-in the Twilio stack; let alone within Twilio Studio. The last time this question was asked in detail was in 2013 so your help is greatly appreciated. I am looking to find a solution to the following to educate myself and others:
[Round Robin Scenario]
Mentioned by Phil Krnjeu on Aug 1 '13 at 23:04, "I'm trying to create a website that has a phone number on it (say, a phone number for a school). When you call that number, it has different secretary offices (A,B,C, D). I want to create something where the main number is called, and then it goes and calls phone number A the first time, the second time someone calls the main number, number B is called, C, then D. Once D is called (which would be the 4th call), the 5th call goes back to A."
The response to the above question was to use an IVR Screening & Recording application which requires the caller to pick an agent which is not a true Round Robin solution. The solution I am looking for and many others require the system to know which agent is in a group and which agent is next to receive a call.
[Key Features Needed]
Ability to add forwarding numbers as identified above A, B, C, D as a group or IVR extensions such as 1 = Management, 2 = Sales and etc...
Set a subsequent calling rule that notates in a DB of some sort. Caller A through D, for example, equals 1 unsuccessful. When caller A has been forwarded a call it now equals 0 successful then the script stops and allows the call to be answered by the user or its voicemail. Then the next call comes in and is forwarded to user B and assigned a 0 successful value, then the script stops.
After the caller finishes the call or finishes leaving a voicemail the script needs to end the call.
[Final Destination]
The round-robin should finalize its call with the forwarded phone numbers voicemail.
[Known Issues]
Forwarding a call to multiple numbers not stopping when someone answers
[Options]
Once this question is posted I am sure someone will ask in the near future what if I wanted the call to be forwarded to a Twilio voicemail instead of using the forwarded phone number's voicemail which could be let's say a cell phone. I do not necessarily need this feature, however, making an additional comment would be very helpful to the community. Thank you for your time.
I have limited knowledge of programming besides having the ability to review articles posted by other users. One article I researched in detail that did not work for me was, "IVR: Screening & Recording with PHP and Laravel."
The solution I am looking for first would be to make this code through the new Twilio Studio interface if that is not possible then any other solution would be helpful to all.
Sam here from the Twilio Support Team. You can build what you've described using Twilio's Runtime suite, Studio, and Functions.
I wrote a blog post with detailed instructions and screenshots here, and I've included a summarized version below as well.
CREATE YOUR VARIABLE
First, you need to create a serverless Variable which will be used as the round robin counter. The variable must be inside an Environment, which is inside a Service. This is the only part of the application where you will need your own laptop. You can see how to create these with any of the SDKs or using curl in the docs.
Create a Service
Create an Environment
Create a Variable
Be sure to copy the SIDs of your Service, Environment, and Variable since you will need that for your function.
For convenience, this is how you create the Variable in NodeJS.
const accountSid = 'your_account_sid';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.serverless.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.variables
.create({key: 'key', value: 'value'})
.then(variable => console.log(variable.sid));
CREATE YOUR FUNCTION
Create the following Environment Variables here in the console and save set them equal to their respective SID that you saved earlier.
RR_SERVICE_SID
RR_ENV_SID
RR_VAR_SID_CTR
Next, make sure you check the Enable ACCOUNT_SID and AUTH_TOKEN checkbox above the Environment Variables section under Credentials.
Be sure your Twilio Client version in the Dependencies section is set to the latest, so we can be sure it includes the Serverless resources. At the time of writing (March 2020), the default Client version does not include them, so we upgraded to 3.41.1, which was the latest.
Go here in the console and create a blank Function.
Copy and paste the following code and replace the numbers with the ones you would like to include in your Round Robin (make sure the environment variables you just created match what's in the code).
exports.handler = function(context, event, callback) {
// Number List
let numbers = [
"+18652142345", //Sam
"+18651092837", //Tina
"+19193271892", //Matt
// Copy and paste line above to add another number.
];
// Initialize Twilio Client
let client = context.getTwilioClient();
// Fetch Round Robin Ctr
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.fetch()
.then(variable => {
// Use counter value to determine number to call
let number = numbers[variable.value];
// Create var with new ctr value
let ctr = variable.value;
// Check if current counter value is less than RR length (i.e. the number of numbers in round robin)
// If so, increment
if(ctr == numbers.length-1) {
ctr = 0;
}
// Otherwise reset ctr
else ctr++;
// Update counter value
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.update({value: ctr})
.then(resp => {
// Return number to call
let response = {number};
// Return our counter value and a null error value
callback(null, response);
});
});
};
CREATE YOUR STUDIO FLOW
Click the red plus sign to create a new Flow here.
Give the Flow a name and click Next.
Scroll to the bottom of the templates and click 'Import from JSON' and click Next.
Paste the Flow JSON shown here and click Next.
Click the RoundRobin function widget and select the Function you just created under the Default service.
Click the FunctionError widget, click MESSAGING & CHAT CONFIG, and change the SEND MESSAGE TO number to a number that you would like to notify by text in the event of a Function failure.
Click the DefaultNumber widget and change the default number that will be forwarded to in the event of a Function failure.
Click the Publish button at the top of your Flow.
CONFIGURE YOUR TWILIO NUMBER
Go here in the console.
Click the Twilio number you would like to configure.
Scroll down to the A CALL COMES IN dropdown in the Voice section and select Studio Flow.
Select your new Flow in the Select a Flow dropdown to the right.
Click Save at the bottom.
And that's it. You're now all set to test!

How to update only the StatusCode of an entity in MS CRM Dynamics 2013

I'm trying to update a Quote status code in MS CRM 2013 via the SDK. The issue is that I only need to update the status code and not the state code in the quote. The current State of the quote is Active and the current Status value is 10 (which I need to update to 11). I've tried a few things unsuccessfully so far:
Using the Microsoft.Crm.Sdk.Messages.SetStateRequest(), setting only the Status property:
var request = new SetStateRequest
{
EntityMoniker = new EntityReference("quote", quoteId),
Status = new OptionSetValue(11)
};
var resp = (SetStateResponse) orgService.Execute(request);
// throws Exception Microsoft.Xrm.Sdk.OrganizationServiceFault:
// "Required field 'State' is missing"
Using the Microsoft.Crm.Sdk.Messages.SetStateRequest(), setting both Status and the State property (setting the new State to the same current value):
var request = new SetStateRequest
{
EntityMoniker = new EntityReference("quote", quoteId),
State = new OptionSetValue((int) QuoteState.Active),
Status = new OptionSetValue(11)
};
var resp = (SetStateResponse) orgService.Execute(request);
// throws Exception Microsoft.Xrm.Sdk.OrganizationServiceFault:
// "The quote cannot be activated because it is not in draft state."
Calling the Update method (passing in a quote instance) in the Microsoft.Xrm.Sdk.Client.OrganizationServiceContext class. I don't have the exact code I used when I tried this, but the error I was getting was:
"The object cannot be updated because it is read-only."
I made sure the connection was made using admin user credentials, but it didn't make a difference. I also found a few other posts like this one: read-only entity error but that didn't help either.
Question
Is there a way to programmatically update the Quote status code without altering the state code? If so, how?
The Status Reason (statuscode field) of a entity depends on the Status (statecode field) value.
For example the standard values for a Quote are the following
so inside your SetStateRequest you need to set the a valid combination (for example you can't set a quote to be Active and Revised) specifying both the values.
In your question you wrote that you are using custom Status Reason, you need to check under which Status you added them and try again.
Seems like my issue has to do with the current state of the quote - Active. Apparently, Active quotes cannot be updated for the most part - I wasn't able to update its status reason even through the GUI. I found this post with a similar scenario.
As the post suggests, I was able to programmatically update my quote status by first sending it back to Draft/In Progress, and then updating its state/status to Active/11.

equivalent to global "before_filter" in Yesod

I have been attempting to play with Yesod, and I have run into a very simple problem that I can not seem to find a solution to.
Say I want to have a global function, that runs on every request irrelevantly of route or handler (for example an authentication function). Say I want something like
uid <- requireAuthId
to run before every handler function and return control to the handler function when a uid is provided / if it already exists
Where would I slot this in? What is the 'Yesod Way' of doing before filters?
One way to do this is to modify your Yesod instance for your foundation type. Assuming your foundation type is called App, you can do the following to force authorization before any other handlers are called.
instance Yesod App where --the following lines are somewhere within this block.
isAuthorized (AuthR LoginR) _ = return Authorized -- You don't want to accidentally lose access to the login page!
isAuthorized _ _ = do
mauth <- maybeAuth
case mauth of
Just _ -> return Authorized
Nothing -> return $ Unauthorized "You must login first."
Obviously, edit this to suit your needs, but it should give you an idea of how to do this.

wfNotify in IDOC to send mail | csScriptMustBeInWorkflowContext

I have created & called a custom service in my custom template to send mails to users when document gets sent/reject/approve. I want to copy myself in BCC in these mails so that in case of any issues, i could cross check. is there a way i can enter a specific mail address in this code. below is the code i 'm using. Will "wfNotify" be of any help?
code used
<$executeService("APPROVAL_MAIL_PILOT_USERS")$>
<$loop IS_PILOT_USER$>
<$userValue=IS_PILOT_USER.USEREXISTS$>
<$endloop$>
<$if strEqualsIgnoreCase(userValue,"1")$>
----MailFormat----
P.S- when i use wfNotify -> , i get the error
Caused by: intradoc.common.ServiceException: !csScriptMustBeInWorkflowContext,wfNotify
*ScriptStack !csDynHTMLStackDumpStart,pbhati,(datasummary)IdcService=WORKFLOW_SENDTO\,dDocName=D_1247583\,dID=1421894!$
!csDynHTMLNoStack!$
!csDynHTMLErrorMessage,/u01/Oracle/Middleware/user_projects/domains/base_domain/ucm/cs/custom/Workflow/templates/Workflow_reviewer_mail.htm,44,3!csDynHTMLReportMsgFunction,wfNotify!$
-><$wfNotify(xDocOwner,"user")$>
As far as I know, wfNotify can only be called from inside a workflow event which is why you are receiving the csScriptMustBeInWorkflowContext error.
As to a service or Idoc Script function (besides wfNotify) that can be used to send an email to a specific user/alias/token and use a custom template, I could not locate one.
You could create your own scriptable service (which you can then call from Idoc Script) or an Idoc Script function that would allow for this.
You can call wfNotify with the specific username.
But the user must have their email details completed in the user table.
Your second error with the wfNotify call - are you calling wfNotify with a 3rd param for the template?
If so - eliminate this as a source of your problem by just calling wfNotify with the first two params.
wfNotify Oracle Documentation

Update Rails session with Backbone.js history navigate?

I have a Market stored in a user session in Rails, set via session[:current_market] in my application_controller.rb.
I have my front-end interface served with Backbone.js, and I have a little market selector widget that calls
BackboneApp.data.currentMarket = market.toJSON()
Backbone.history.navigate market.homeUrl(), trigger: true
... when a user selects a market. This works except that if a user hard-navigates to another page, the market reverts to whatever it was set on the initial page load (whatever was originally loaded in session[:current_market] in Rails.
How can I update the user's market in session when a Backbone.js navigation event occurs?
I tried manually doing this by triggering a silent GET:
$.get '/api/v1/reset_current_market', { market_id: market.toJSON().id }
... but that doesn't seem to work.
I assume that when the user switches market then some ajax request will be fired to hit your rails api and fetch the data for that market. What you could do is make the controller action for that route update the current users session to whatever market got requested.
how about wrap this market info to new Model and handling change with that? This is just a pseudo code examlpe.
var marketModel = Backbone.Model.extend({
urlRoot:"/you/url/market",
defaults:{
marker: ""
},
initialize:function () {
}
});
BackboneApp.data.currentMarket = new marketModel(market.toJSON())
Set selected market to this new model, and call save().
At rails change session info at your /your/url/marget POST method. If this object have id property then impelent also PUT method.