crm 2011 when update a field in account entity there is no change - dynamics-crm-2011

Well, my problem is the follow. I create a entity. i call this new_logpuntossegmentacin that has a relation 1 to ∞ with account, when i put in the registration plugin message, create i hope that the follow code fill out the field puntosacumulados but nothing happens:
cli is a Account from a List
total is a Decimal
total = total1 + total2 + total3 + total4 + total5 + total6;
cli.new_puntosacumulados.Insert(i, total.ToString());
svcContext.UpdateObject(cli);
svcContext.SaveChanges();
i++;
if (!String.IsNullOrEmpty(total.ToString()))
{
tracingService.Trace("Response = {0}", total.ToString());
}
tracingService.Trace("Done.");

A couple of questions which may give a little more context:-
1) When you say nothing happens, do you mean that the value is not updated in the database or it doesn't appear updated on the form? If the latter then it may be when the plug in is firing (pre vs post).
2) Could you perhaps post the rest of the method as it may be useful to get some context on some of the other parameters, e.g. what is "i" iterating over here?
Thanks

Related

How does one access an Extension to a table in Acumatica Business Logic

Apologies if this question has been answered elsewhere, I have had trouble finding any resources on this.
The scenario is this. I have created a custom field in the Tax Preferences screen called Usrapikey.
This value holds an api key for a call that gets done in some custom business logic.
The custom business logic however occurs on the Taxes screen.
So within the event handler I need to access that API key value from the other screen. I have tried instantiating graphs and using linq and bql but to no avail.
below is what I have currently and my error is: No overload for method 'GetExtension' takes 1 arguments
If I am going about this the wrong way please let me know if there is a more civilized way to do this
protected virtual void _(Events.FieldUpdated<TaxRev, TaxRev.startDate> e)
{
var setup = PXGraph.CreateInstance<TXSetupMaint>();
var TXSetupEX = setup.GetExtension<PX.Objects.TX.TXSetupExt>(setup);
var rateObj = GetValues(e.Row.TaxID, TXSetupEX.Usrapikey);
decimal rate;
var tryRate = (Decimal.TryParse(rateObj.rate.combined_rate, out rate));
row.TaxRate = (decimal)rate * (decimal)100;
row.TaxBucketID = 1;
}
Many Thanks!
Well, acumatica support got back. It seems if you want to access the base page use:
TXSetup txsetup = PXSetup<TXSetup>.Select(Base);
To get the extension use:
TXSetupExt rowExt = PXCache<TXSetup>.GetExtension<TXSetupExt>(txsetup);
Then you can access the extension fields like so:
var foo = rowExt.Usrfield;

Paginating a mongoose mapReduce, for a ranking algorithm

I'm using a MongoDB mapReduce to code a ranking feed algorithm, it almost works but the latest thing to implement is the pagination. The map reduce supports the results limitation but how could I implement the offset (skipping) based e.g. on the latest viewed _id of the results, knowing that I'm using mongoose?
This is the procedure I wrote:
o = {};
o.map = function() {
//log10(likes+comments) / elapsed hours from the post creation
emit(Math.log(this.likes + this.comments + 1) / Math.LN10 / Math.abs((now - this.createdAt) / 6e7 + 1), this);
};
o.reduce = function(key, values) {
//sort the values, when they have the same score
values.sort(function(a, b) {
a.createdAt - b.createdAt;
});
//serialize the values, because mongoose does not support multiple returned values
return JSON.stringify(values);
};
o.scope = {now: new Date()};
o.limit = 15;
Posts.mapReduce(o, function(err, results) {
if (err) return console.log(err);
console.log(results);
});
Also, if the mapReduce it's not the way to go, do you suggest other on how to implement something like this?
What you need is a page delimiter which is not the id of the latest viewed as you say, but your sorting property. In this case, it seems to be the formula Math.log(this.likes + this.comments + 1) / Math.LN10 / Math.abs((now - this.createdAt) / 6e7 + 1).
So, in your mapReduce query needs to hold a where value of that formula above. Or specifically, 'formula >= . And also it needs to hold the value of createdAt at the last page, since you don't sort by that. (Assuming createdAt is unique). So yourqueryof mapReduce would saywhere: theFormulaExpression, createdAt: { $lt: lastCreatedAt }`
If you do allow multiple identical createdAt values, you have to play a little outside of the database itself.
So you just search by formula.
Ideally, that gives you one element with exactly that value, and the next ones sorted after that. So in reply to the module caller, remove this first element off the array (and make sure you actually ask for more results then you need because of this).
Now, since you allow for multiple similar values, you need another identifying prop, say, object id or created_at. Your consumer (caller of this module) will have to provide both (last value of the score, createdAt of the last object). Say you have a page split exactly in the middle - one or more objects is on the previous page, another set on the next
. You'd have to not simply remove the top value (because that same score is already served on the previous page), but possibly several of them from the top.
Then it goes really crazy, because potentially your whole page was already served - compare the _ids, look for the first one after the one your module caller has provided you with. Or look into the data and determine how many matching values like that are there, try to get at least as many more values from mapReduce then you have on your actual page size.
Aside from that, I would do this with aggregation instead, it should be much more preformant.

ExpressCheckout with recurring payments -- Cannot find solution

I have been trying to set up an ExpressCheckout with recurring payments but I don't find the solution.
Having a look at the documentation (Recurring Payments With the Express Checkout API), the diagram gives a sequence where "CreateRecurringPaymentsProfile" is invoked at the end.
Now, having a look at the other documentation (How to Create a Recurring Payments Profile with Express Checkout), the different steps which are explained give a different sequence order, where "CreateRecurringPaymentsProfile" comes directly after "GetExpressCheckoutDetails".
I tried to follow this second example but I systematically receive an error.
Could someone tell me what I exactly need to do?
Of course a practical example would be more than welcome...
In advance, many thanks
Additional information:
The error I am receiving is "INVALID TOKEN".
Here is the information I send:
VERSION=84.0
METHOD=CreateRecurringPaymentsProfile
LOCALECODE=FR
TOKEN=[the one I received from SetExpressCheckout]
PROFILESTARTDATE=[the date of the next payment]
BILLINGPERIOD=Month
BILLINGFREQUENCY=6
TOTALBILLINGCYCLES=0
AMT=[the same as I mentioned in PAYMENTREQUEST_0_AMT]
AUTOBILLAMT=AddToNextBilling
CURRENCYCODE=EUR
MAXFAILEDPAYMENTS=3
DESC=[the same as I mentioned in L_BILLINGAGREEMENTDESCRIPTION0]
L_PAYMENTREQUEST_0_NAME0=[the same as I used in SetExpressCheckout]
L_PAYMENTREQUEST_0_DESC0=[the same as I used in SetExpressCheckout]
L_PAYMENTREQUEST_0_AMT0=[the same as I used in SetExpressCheckout]
L_PAYMENTREQUEST_0_QTY0=[the same as I used in SetExpressCheckout]
L_PAYMENTREQUEST_0_TAXAMT0=[the same as I used in SetExpressCheckout]
Do I also need to mention:
L_BILLINGAGREEMENTDESCRIPTION0 & L_BILLINGTYPE0 ?
In case you get 11502 Invalid token, you will need to pass the following variables in your SetEC API request:
BILLINGAGREEMENTDESCRIPTION=Your billing agreement name
BILLINGTYPE=RecurringPayments
Please, check below how EC+RP flow works:
1) SetExpressChekout + BILLINGAGREEMENTDESCRIPTION and BILLINGTYPE variables
VERSION = 86.0
METHOD = SetExpressCheckout
RETURNURL =
http://www.website.com/return.php
CANCELURL =
http://www.website.com/cancel.php
PAYMENTREQUEST_0_CURRENCYCODE =
USD
PAYMENTREQUEST_0_PAYMENTACTION = SALE
L_BILLINGTYPE0 =
RecurringPayments
L_BILLINGAGREEMENTDESCRIPTION0 = SameEveryTime
PAYMENTREQUEST_0_AMT = 1.00
PAYMENTREQUEST_0_ITEMAMT = 1.00
PAYMENTREQUEST_0_DESC = Labs
L_PAYMENTREQUEST_0_NAME0 = Lab 1
L_PAYMENTREQUEST_0_NUMBER0 = 10101
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 1.00
L_PAYMENTREQUEST_0_DESC0 = Download
2) Login into your PayPal account and click on “Accept and Continue”
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2EJ022116H3067544
Buyer logs into his PayPal account and click on the button “Agree and Continue”,
then he will be redirect to RETURNURL+ token+ PayerID:
http://www.website.com/return.php?token=EC-2EJ022116H3067544&PayerID=HHHAPCFUM9ULW
3) Then you can run CreateRecurringPaymentsProfile + token:
PROFILEREFERENCE=RPInvoice123
PROFILESTARTDATE=2016-08-17T14:30:00Z
SUBSCRIBERNAME=Mr Sub Scriber
METHOD=CreateRecurringPaymentsProfile
TOKEN=XXXXXXXXXXXXX
DESC=SameEveryTime
AMT = 1.00
BILLINGPERIOD=Day
BILLINGFREQUENCY=3
VERSION=86.0
MAXFAILEDPAYMENTS=1
L_PAYMENTREQUEST_0_AMT0=1.00
L_PAYMENTREQUEST_0_NAME0=Lab 1
L_PAYMENTREQUEST_0_NUMBER0=10101
L_PAYMENTREQUEST_0_QTY0=1
L_BILLINGTYPE0=RecurringPayments
L_BILLINGAGREEMENTDESCRIPTION0=SameEveryTime
L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital
and this is the NVP Response:
PROFILEID=I-TOKEN123456
PROFILESTATUS=ActiveProfile
TIMESTAMP=2013-11-22T04:06:50Z
CORRELATIONID=2b5be15a871ff
ACK=Success
VERSION=86.0
BUILD=5908853
Documentation:
ECRecurringPayments
API references (NVP)
SetExpressCheckout API request
CreateRecurringPayment API request

Flickr api doesn't return the estimated value

I am using flickr api in order to count the how many times a tag occur. I want this information in order to calculate the Normalized Google Distance. I am using this query in my java code:
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=XXXXXXX&format=json&tags=bank
But i don't get good results. For example when i search "bank" the count value is 357439, when i search "credit" the count value is 59288, but when i am search for "bank credit" the count value is only 2. When i searching with the search box at flickr.com for "bank credit" i get a lot of results. But as far as i can see the query it uses is
http://www.flickr.com/search/?q=bank%20credit
which i am not able to use through my java code. I am trying to pass this
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=XXXXXXX&format=json&q=bank
and it says
Parameterless searches have been disabled. Please use flickr.photos.getRecent instead
How can i solve this problem?
Your generated url is incorrect
http://api.flickr.com/services/rest/method=flickr.photos.search&api_key=XXXXXXX&format=json&q=bank
is missing the question mark
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=XXXXXXX&format=json&q=bank
UPDATE based on OP comments:
I didn't see you had the question mark on the top url string. Looking at it again, I did realize you are not passing in any valid parameters. "q" isn't one of the listed parameters on the search api page. Try something like below to search photos with "bank" tag
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=XXXXXXX&format=json&tags=bank
or one with bank in description/title
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=XXXXXXX&format=json&text=bank
I got the same error. but when I added media = photos in the parameters, it got resolved.
e.g. :
baseurl = "https://api.flickr.com/services/rest/"
params_d['api_key'] = 'XXXXXXX'
params_d['method'] = 'flickr.photos.search'
params_d['tag'] = "river,mountains"
params_d['tag_mode'] = 'all'
params_d['per_page'] = 5
params_d['media'] = "photos"
params_d['nojsoncallback'] = 1
params_d['format'] = 'json'
resp = requests.get(baseurl, params = params_d)

CRM 2011 oData query confusion

I am very new to CRM development, i was trying to follow this article, i am a bit confused about below code, please check:
var xp = Xrm.Page;
function onLoad(context) {
var accountId = xp.data.entity.getId();
var mostRecentQuery = "/XRMServices/2011/organizationData.svc/ContactSet?
$select=FullName,JobTitle,EMailAddress1,Telephone1&$top=1&$orderby=CreatedOn
desc&$filter=ParentCustomerId/Id eq guid'" + accountId + "'";
getContact(mostRecentQuery, "MostRecent");
....
}
The above javascript function executes when AccountForm is opened. The first line gets the accountId. the next line is oData query.
Now check the ContactSet in this query, i am confused here, how we can retrieve the ContactEntity based on the GUID of AccountEntity?
I found the answer!
Actually there a Lookup 'Parent Customer' on ContactEntity, it represents the unique identifier of the account or contact associated with this contact, so we can select an Account/Contact as the Parent Customer of a contact.
So this given OData query actually retrieves the top 1 contact where this account is referenced.
I hope its clear.

Resources