vendredi 11 septembre 2015

Dynamics CRM 2015 - update Opportunity Owner id via javascript

I'm trying to update the OwnerId on an opportunity in Dynamics CRM 2015.

So far I am using the following code but my changes are not taking effect.

Xrm.Page.data.entity.attributes.get('ownerid').setValue('487ecd0c-d8c1-e411-80eb-c4346bade4b0')
Xrm.Page.data.entity.save();

This is a view of the GetValue call.

enter image description here

The attribute type is "lookup" and when I call getIsDirty(), it returns false after I do setValue, so I'm not sure if that's the correct way to set the value on a "lookup" type.



via Chebli Mohamed

Bash readline history previous line before history expansion

There are usually the keys Up and Ctrl+P mapped to previous-history Readline command in Bash which moves back in history to previous line with history expanded.

How to move to the previous line before History expansion? E.g. to line like

!!:gs/20010910/20010911/



via Chebli Mohamed

Should I use sync or blocking channels?

I have several go routines and I use unbuffered channels as sync mechanism. I'm wondering if there is anything wrong in this(e.g. compared with a WaitGroup implementation). A known "drawback" that I'm aware of is that two go routines may stay blocked until the 3rd(last) one completes because the channel is no buffered but I don't know the internals/what this really means.

func main() {
    chan1, chan2, chan3 := make(chan bool), make(chan bool), make(chan bool)
    go fn(chan1)
    go fn(chan2)
    go fn(chan3)
    res1, res2, res3 := <-chan1, <-chan2, <-chan3
}



via Chebli Mohamed

Polymer 1.0: google-signin sign in still success when user revoke permissions

I am using a google-signin element to have access to user's access scopes. I found, if I as a user authorize the my app with certain scopes, then revoke those scopes without clicking on "Sign out" button (basically the google-signin element), the google-sign is result as onSigninSuccess event even without the authorization.

This is weird. It should be onSigninFailure because the app doesn't have the corresponding scopes of authorizations from the user.



via Chebli Mohamed

Printing numbers

I am writing a program to display as below

when n=3
1 2 3
7 8 9
4 5 6

when n=5
1 2 3 4 5
11 12 13 14 15
21 22 23 24 25
16 17 18 19 20
6 7 8 9 10

my program is

#include<stdio.h>
#include<conio.h>
int main()
{
    int n=5,r=1,c=1,i=1,mid=0;
    if(n%2==0)
      mid=(n/2);
    else 
      mid=(n/2)+1;
      printf("mid = %d\n",mid);
    while(r<=n)
    {
      while(c<=n)
      {
        printf("%d ",i);
        c++;
        i++;
      }
      r++;
      if(r<=mid)
       i=i+n;
      else
       i=i-(2*n);
      printf("\n");
      c=1;
    }
    getch();
    return 0;
}

when I give n=3, I am getting my expected output. but when I give n=5 I am getting as below

1 2 3 4 5
11 12 13 14 15
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15

Could someone please help how to achieve expected output.



via Chebli Mohamed

How to process data in object collection?

Now, in my object collection,obj:

{date:2015/9/11,name:Ann,apple:1},
{date:2015/9/12,name:Ann,apple:0},
{date:2015/9/13,name:Ann,apple:1},
{date:2015/9/11,name:Bob,apple:1},.....

and I print it out like this:

2015/9/11  Ann     1  
2015/9/12  Ann     0  
2015/9/13  Ann     1  
2015/9/11  Bob     1  
2015/9/12  Bob     1  
2015/9/13  Bob     1  

Here is my code

var index, objLen
for (index = 0, objLen = obj.length; index<objLen; ++index){
    console.log(obj[index].date +'\t'+ obj[index].name +'\t'+ result[index].apple)
}

I wish to output:

2015/9/13  Ann     2  
2015/9/13  Bob     3 

This shows how many apples Ann and Bob have eaten in this three days

I want to know how to get the output.



via Chebli Mohamed

Difference between \z and \Z and \a and \A in Perl

Hello Can you please tell me the difference between \z and \Z as well as \a and \A in Perl with a simple example ?



via Chebli Mohamed